Search in sources :

Example 56 with TargetApi

use of android.annotation.TargetApi in project android-beacon-library by AltBeacon.

the class BeaconManager method stopMonitoringBeaconsInRegion.

/**
     * Tells the <code>BeaconService</code> to stop looking for beacons that match the passed
     * <code>Region</code> object.  Note that the Region's unique identifier is used to match it to
     * an existing monitored Region.
     *
     * @param region
     * @see BeaconManager#setMonitorNotifier(MonitorNotifier)
     * @see BeaconManager#startMonitoringBeaconsInRegion(Region region)
     * @see MonitorNotifier
     * @see Region
     */
@TargetApi(18)
public void stopMonitoringBeaconsInRegion(Region region) throws RemoteException {
    if (android.os.Build.VERSION.SDK_INT < 18) {
        LogManager.w(TAG, "Not supported prior to API 18.  Method invocation will be ignored");
        return;
    }
    if (serviceMessenger == null) {
        throw new RemoteException("The BeaconManager is not bound to the service.  Call beaconManager.bind(BeaconConsumer consumer) and wait for a callback to onBeaconServiceConnect()");
    }
    Message msg = Message.obtain(null, BeaconService.MSG_STOP_MONITORING, 0, 0);
    StartRMData obj = new StartRMData(region, callbackPackageName(), this.getScanPeriod(), this.getBetweenScanPeriod(), this.mBackgroundMode);
    msg.obj = obj;
    serviceMessenger.send(msg);
}
Also used : Message(android.os.Message) StartRMData(org.altbeacon.beacon.service.StartRMData) RemoteException(android.os.RemoteException) TargetApi(android.annotation.TargetApi)

Example 57 with TargetApi

use of android.annotation.TargetApi in project acra by ACRA.

the class MediaCodecListCollector method collectCapabilitiesForType.

/**
     * Retrieve capabilities (ColorFormats and CodecProfileLevels) for a
     * specific codec type.
     *
     * @param codecInfo the currently inspected codec
     * @param type      supported type to collect
     * @return the color formats and codec profile levels
     * available for a specific codec type.
     */
@NonNull
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private JSONObject collectCapabilitiesForType(@NonNull final MediaCodecInfo codecInfo, @NonNull String type) throws JSONException {
    final JSONObject result = new JSONObject();
    final MediaCodecInfo.CodecCapabilities codecCapabilities = codecInfo.getCapabilitiesForType(type);
    // Color Formats
    final int[] colorFormats = codecCapabilities.colorFormats;
    if (colorFormats.length > 0) {
        JSONArray colorFormatsJson = new JSONArray();
        for (int colorFormat : colorFormats) {
            colorFormatsJson.put(mColorFormatValues.get(colorFormat));
        }
        result.put("colorFormats", colorFormatsJson);
    }
    final CodecType codecType = identifyCodecType(codecInfo);
    // Profile Levels
    final MediaCodecInfo.CodecProfileLevel[] codecProfileLevels = codecCapabilities.profileLevels;
    if (codecProfileLevels.length > 0) {
        JSONArray profileLevels = new JSONArray();
        for (MediaCodecInfo.CodecProfileLevel codecProfileLevel : codecProfileLevels) {
            final int profileValue = codecProfileLevel.profile;
            final int levelValue = codecProfileLevel.level;
            if (codecType == null) {
                // Unknown codec
                profileLevels.put(profileValue + '-' + levelValue);
                break;
            }
            switch(codecType) {
                case AVC:
                    profileLevels.put(profileValue + mAVCProfileValues.get(profileValue) + '-' + mAVCLevelValues.get(levelValue));
                    break;
                case H263:
                    profileLevels.put(mH263ProfileValues.get(profileValue) + '-' + mH263LevelValues.get(levelValue));
                    break;
                case MPEG4:
                    profileLevels.put(mMPEG4ProfileValues.get(profileValue) + '-' + mMPEG4LevelValues.get(levelValue));
                    break;
                case AAC:
                    profileLevels.put(mAACProfileValues.get(profileValue));
                    break;
                default:
                    break;
            }
        }
        result.put("profileLevels", profileLevels);
    }
    return result;
}
Also used : JSONObject(org.json.JSONObject) MediaCodecInfo(android.media.MediaCodecInfo) JSONArray(org.json.JSONArray) NonNull(android.support.annotation.NonNull) TargetApi(android.annotation.TargetApi)

Example 58 with TargetApi

use of android.annotation.TargetApi in project acra by ACRA.

the class MediaCodecListCollector method collectMediaCodecList.

/**
     * Builds an Element describing the list of available codecs on the device
     * with their capabilities (supported Color Formats, Codec Profiles et
     * Levels).
     *
     * @return The media codecs information
     */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@NonNull
private Element collectMediaCodecList() throws JSONException {
    prepare();
    final MediaCodecInfo[] infos;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        //noinspection deprecation
        final int codecCount = MediaCodecList.getCodecCount();
        infos = new MediaCodecInfo[codecCount];
        for (int codecIdx = 0; codecIdx < codecCount; codecIdx++) {
            //noinspection deprecation
            infos[codecIdx] = MediaCodecList.getCodecInfoAt(codecIdx);
        }
    } else {
        infos = new MediaCodecList(MediaCodecList.ALL_CODECS).getCodecInfos();
    }
    final ComplexElement result = new ComplexElement();
    for (int i = 0; i < infos.length; i++) {
        final MediaCodecInfo codecInfo = infos[i];
        JSONObject codec = new JSONObject();
        final String[] supportedTypes = codecInfo.getSupportedTypes();
        codec.put("name", codecInfo.getName()).put("isEncoder", codecInfo.isEncoder());
        JSONObject supportedTypesJson = new JSONObject();
        for (String type : supportedTypes) {
            supportedTypesJson.put(type, collectCapabilitiesForType(codecInfo, type));
        }
        codec.put("supportedTypes", supportedTypesJson);
        result.put(String.valueOf(i), codec);
    }
    return result;
}
Also used : JSONObject(org.json.JSONObject) MediaCodecInfo(android.media.MediaCodecInfo) MediaCodecList(android.media.MediaCodecList) ComplexElement(org.acra.model.ComplexElement) NonNull(android.support.annotation.NonNull) TargetApi(android.annotation.TargetApi)

Example 59 with TargetApi

use of android.annotation.TargetApi in project android_frameworks_base by DirtyUnicorns.

the class MediaDecoder method retrieveDefaultRotation.

@TargetApi(17)
private void retrieveDefaultRotation() {
    MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
    metadataRetriever.setDataSource(mContext, mUri);
    String rotationString = metadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
    mDefaultRotation = rotationString == null ? 0 : Integer.parseInt(rotationString);
}
Also used : MediaMetadataRetriever(android.media.MediaMetadataRetriever) TargetApi(android.annotation.TargetApi)

Example 60 with TargetApi

use of android.annotation.TargetApi in project android_frameworks_base by DirtyUnicorns.

the class RenderTarget method forSurface.

@TargetApi(11)
public RenderTarget forSurface(Surface surface) {
    EGLConfig eglConfig = chooseEglConfig(mEgl, mDisplay);
    EGLSurface eglSurf = null;
    synchronized (mSurfaceSources) {
        eglSurf = mSurfaceSources.get(surface);
        if (eglSurf == null) {
            eglSurf = mEgl.eglCreateWindowSurface(mDisplay, eglConfig, surface, null);
            mSurfaceSources.put(surface, eglSurf);
        }
    }
    checkEglError(mEgl, "eglCreateWindowSurface");
    checkSurface(mEgl, eglSurf);
    RenderTarget result = new RenderTarget(mDisplay, mContext, eglSurf, 0, false, true);
    result.setSurfaceSource(surface);
    result.addReferenceTo(eglSurf);
    return result;
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface) EGLConfig(javax.microedition.khronos.egl.EGLConfig) TargetApi(android.annotation.TargetApi)

Aggregations

TargetApi (android.annotation.TargetApi)1365 Intent (android.content.Intent)153 View (android.view.View)147 Test (org.junit.Test)119 SuppressLint (android.annotation.SuppressLint)115 Uri (android.net.Uri)70 ArrayList (java.util.ArrayList)68 Animator (android.animation.Animator)67 Point (android.graphics.Point)64 Window (android.view.Window)56 TextView (android.widget.TextView)56 IOException (java.io.IOException)56 ViewGroup (android.view.ViewGroup)53 Matchers.anyString (org.mockito.Matchers.anyString)53 SharedPreferences (android.content.SharedPreferences)44 File (java.io.File)44 Field (java.lang.reflect.Field)44 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)43 Bitmap (android.graphics.Bitmap)42 ImageView (android.widget.ImageView)40