Search in sources :

Example 31 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class View method updateDisplayListIfDirty.

/**
     * Gets the RenderNode for the view, and updates its DisplayList (if needed and supported)
     * @hide
     */
@NonNull
public RenderNode updateDisplayListIfDirty() {
    final RenderNode renderNode = mRenderNode;
    if (!canHaveDisplayList()) {
        // can't populate RenderNode, don't try
        return renderNode;
    }
    if ((mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) == 0 || !renderNode.isValid() || (mRecreateDisplayList)) {
        // children to restore/recreate theirs
        if (renderNode.isValid() && !mRecreateDisplayList) {
            mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID;
            mPrivateFlags &= ~PFLAG_DIRTY_MASK;
            dispatchGetDisplayList();
            // no work needed
            return renderNode;
        }
        // If we got here, we're recreating it. Mark it as such to ensure that
        // we copy in child display lists into ours in drawChild()
        mRecreateDisplayList = true;
        int width = mRight - mLeft;
        int height = mBottom - mTop;
        int layerType = getLayerType();
        final DisplayListCanvas canvas = renderNode.start(width, height);
        canvas.setHighContrastText(mAttachInfo.mHighContrastText);
        try {
            if (layerType == LAYER_TYPE_SOFTWARE) {
                buildDrawingCache(true);
                Bitmap cache = getDrawingCache(true);
                if (cache != null) {
                    canvas.drawBitmap(cache, 0, 0, mLayerPaint);
                }
            } else {
                computeScroll();
                canvas.translate(-mScrollX, -mScrollY);
                mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID;
                mPrivateFlags &= ~PFLAG_DIRTY_MASK;
                // Fast path for layouts with no backgrounds
                if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) {
                    dispatchDraw(canvas);
                    if (mOverlay != null && !mOverlay.isEmpty()) {
                        mOverlay.getOverlayView().draw(canvas);
                    }
                } else {
                    draw(canvas);
                }
            }
        } finally {
            renderNode.end(canvas);
            setDisplayListProperties(renderNode);
        }
    } else {
        mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID;
        mPrivateFlags &= ~PFLAG_DIRTY_MASK;
    }
    return renderNode;
}
Also used : Bitmap(android.graphics.Bitmap) Paint(android.graphics.Paint) Point(android.graphics.Point) NonNull(android.annotation.NonNull)

Example 32 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class ResourcesManager method getOrCreateResourcesLocked.

/**
     * Gets an existing Resources object if the class loader and ResourcesImpl are the same,
     * otherwise creates a new Resources object.
     */
@NonNull
private Resources getOrCreateResourcesLocked(@NonNull ClassLoader classLoader, @NonNull ResourcesImpl impl) {
    // Find an existing Resources that has this ResourcesImpl set.
    final int refCount = mResourceReferences.size();
    for (int i = 0; i < refCount; i++) {
        WeakReference<Resources> weakResourceRef = mResourceReferences.get(i);
        Resources resources = weakResourceRef.get();
        if (resources != null && Objects.equals(resources.getClassLoader(), classLoader) && resources.getImpl() == impl) {
            if (DEBUG) {
                Slog.d(TAG, "- using existing ref=" + resources);
            }
            return resources;
        }
    }
    // Create a new Resources reference and use the existing ResourcesImpl object.
    Resources resources = new Resources(classLoader);
    resources.setImpl(impl);
    mResourceReferences.add(new WeakReference<>(resources));
    if (DEBUG) {
        Slog.d(TAG, "- creating new ref=" + resources);
        Slog.d(TAG, "- setting ref=" + resources + " with impl=" + impl);
    }
    return resources;
}
Also used : Resources(android.content.res.Resources) NonNull(android.annotation.NonNull)

Example 33 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class LocaleList method getDefault.

/**
     * The result is guaranteed to include the default Locale returned by Locale.getDefault(), but
     * not necessarily at the top of the list. The default locale not being at the top of the list
     * is an indication that the system has set the default locale to one of the user's other
     * preferred locales, having concluded that the primary preference is not supported but a
     * secondary preference is.
     *
     * <p>Note that the default LocaleList would change if Locale.setDefault() is called. This
     * method takes that into account by always checking the output of Locale.getDefault() and
     * recalculating the default LocaleList if needed.</p>
     */
@NonNull
@Size(min = 1)
public static LocaleList getDefault() {
    final Locale defaultLocale = Locale.getDefault();
    synchronized (sLock) {
        if (!defaultLocale.equals(sLastDefaultLocale)) {
            sLastDefaultLocale = defaultLocale;
            // locale list. So let's recalculate the locale list.
            if (sDefaultLocaleList != null && defaultLocale.equals(sDefaultLocaleList.get(0))) {
                // default locale list, so we don't need to construct a new locale list.
                return sDefaultLocaleList;
            }
            sDefaultLocaleList = new LocaleList(defaultLocale, sLastExplicitlySetLocaleList);
            sDefaultAdjustedLocaleList = sDefaultLocaleList;
        }
        // sDefaultLocaleList.
        return sDefaultLocaleList;
    }
}
Also used : Locale(java.util.Locale) ULocale(android.icu.util.ULocale) Size(android.annotation.Size) NonNull(android.annotation.NonNull)

Example 34 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class ApplicationPackageManager method getPrimaryStorageCandidateVolumes.

@Override
@NonNull
public List<VolumeInfo> getPrimaryStorageCandidateVolumes() {
    final StorageManager storage = mContext.getSystemService(StorageManager.class);
    final VolumeInfo currentVol = getPrimaryStorageCurrentVolume();
    final List<VolumeInfo> vols = storage.getVolumes();
    final List<VolumeInfo> candidates = new ArrayList<>();
    if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, storage.getPrimaryStorageUuid()) && currentVol != null) {
        // TODO: support moving primary physical to emulated volume
        candidates.add(currentVol);
    } else {
        for (VolumeInfo vol : vols) {
            if (Objects.equals(vol, currentVol) || isPrimaryStorageCandidateVolume(vol)) {
                candidates.add(vol);
            }
        }
    }
    return candidates;
}
Also used : StorageManager(android.os.storage.StorageManager) ArrayList(java.util.ArrayList) VolumeInfo(android.os.storage.VolumeInfo) NonNull(android.annotation.NonNull)

Example 35 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class DngCreator method setThumbnail.

/**
     * Set the thumbnail image.
     *
     * <p>
     * Pixel data is interpreted as a {@link android.graphics.ImageFormat#YUV_420_888} image.
     * Thumbnail images with a dimension larger than {@link #MAX_THUMBNAIL_DIMENSION} will be
     * rejected.
     * </p>
     *
     * @param pixels an {@link android.media.Image} object with the format
     *               {@link android.graphics.ImageFormat#YUV_420_888}.
     * @return this {@link #DngCreator} object.
     * @throws java.lang.IllegalArgumentException if the given thumbnail image has a dimension
     *      larger than {@link #MAX_THUMBNAIL_DIMENSION}.
     */
@NonNull
public DngCreator setThumbnail(@NonNull Image pixels) {
    if (pixels == null) {
        throw new IllegalArgumentException("Null argument to setThumbnail");
    }
    int format = pixels.getFormat();
    if (format != ImageFormat.YUV_420_888) {
        throw new IllegalArgumentException("Unsupported Image format " + format);
    }
    int width = pixels.getWidth();
    int height = pixels.getHeight();
    if (width > MAX_THUMBNAIL_DIMENSION || height > MAX_THUMBNAIL_DIMENSION) {
        throw new IllegalArgumentException("Thumbnail dimensions width,height (" + width + "," + height + ") too large, dimensions must be smaller than " + MAX_THUMBNAIL_DIMENSION);
    }
    ByteBuffer rgbBuffer = convertToRGB(pixels);
    nativeSetThumbnail(rgbBuffer, width, height);
    return this;
}
Also used : ByteBuffer(java.nio.ByteBuffer) NonNull(android.annotation.NonNull)

Aggregations

NonNull (android.annotation.NonNull)322 ArrayList (java.util.ArrayList)46 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)45 IOException (java.io.IOException)35 ComponentName (android.content.ComponentName)25 File (java.io.File)22 XmlPullParser (org.xmlpull.v1.XmlPullParser)20 Intent (android.content.Intent)18 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)16 ResolveInfo (android.content.pm.ResolveInfo)16 Bundle (android.os.Bundle)15 RemoteException (android.os.RemoteException)15 FileNotFoundException (java.io.FileNotFoundException)15 Paint (android.graphics.Paint)14 PackageParser (android.content.pm.PackageParser)12 ContentResolver (android.content.ContentResolver)10 UserInfo (android.content.pm.UserInfo)10 StorageManager (android.os.storage.StorageManager)10 VolumeInfo (android.os.storage.VolumeInfo)10 KeyCharacteristics (android.security.keymaster.KeyCharacteristics)10