Search in sources :

Example 1 with ConfigurationInfo

use of android.content.pm.ConfigurationInfo in project android_frameworks_base by ParanoidAndroid.

the class ActivityManagerProxy method getDeviceConfigurationInfo.

public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    data.writeInterfaceToken(IActivityManager.descriptor);
    mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
    reply.readException();
    ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
    reply.recycle();
    data.recycle();
    return res;
}
Also used : Parcel(android.os.Parcel) ConfigurationInfo(android.content.pm.ConfigurationInfo)

Example 2 with ConfigurationInfo

use of android.content.pm.ConfigurationInfo in project Horizon by Yalantis.

the class Horizon method initView.

/**
     * Basic settings for component
     *
     * @param glSurfaceView   - view that will contain the component
     * @param backgroundColor - preferable background color for correct colors blending
     */
private void initView(GLSurfaceView glSurfaceView, @ColorInt int backgroundColor) {
    // check if the system supports opengl es 2.0.
    Context context = glSurfaceView.getContext();
    final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
    if (supportsEs2) {
        // Request an OpenGL ES 2.0 compatible context.
        glSurfaceView.setEGLContextClientVersion(2);
        // Set the renderer to our demo renderer, defined below.
        mRenderer = new BezierRenderer(glSurfaceView, backgroundColor);
        glSurfaceView.setRenderer(mRenderer);
        glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
    } else {
        throw new UnsupportedOperationException();
    }
}
Also used : Context(android.content.Context) BezierRenderer(com.yalantis.waves.gl.BezierRenderer) ActivityManager(android.app.ActivityManager) ConfigurationInfo(android.content.pm.ConfigurationInfo)

Example 3 with ConfigurationInfo

use of android.content.pm.ConfigurationInfo in project jmonkeyengine by jMonkeyEngine.

the class OGLESContext method createView.

/**
     * <code>createView</code> creates the GLSurfaceView that the renderer will
     * draw to. <p> The result GLSurfaceView will receive input events and
     * forward them to the Application. Any rendering will be done into the
     * GLSurfaceView. Only one GLSurfaceView can be created at this time. The
     * given configType specifies how to determine the display configuration.
     *
     * @return GLSurfaceView The newly created view
     */
public GLSurfaceView createView(Context context) {
    // NOTE: We assume all ICS devices have OpenGL ES 2.0.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // below 4.0, check OpenGL ES 2.0 support.
        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo info = am.getDeviceConfigurationInfo();
        if (info.reqGlEsVersion < 0x20000) {
            throw new UnsupportedOperationException("OpenGL ES 2.0 is not supported on this device");
        }
    } else if (Build.VERSION.SDK_INT < 9) {
        throw new UnsupportedOperationException("jME3 requires Android 2.3 or later");
    }
    // Start to set up the view
    GLSurfaceView view = new GLSurfaceView(context);
    logger.log(Level.INFO, "Android Build Version: {0}", Build.VERSION.SDK_INT);
    if (androidInput == null) {
        if (Build.VERSION.SDK_INT >= 14) {
            androidInput = new AndroidInputHandler14();
        } else if (Build.VERSION.SDK_INT >= 9) {
            androidInput = new AndroidInputHandler();
        }
    }
    androidInput.setView(view);
    androidInput.loadSettings(settings);
    // setEGLContextClientVersion must be set before calling setRenderer
    // this means it cannot be set in AndroidConfigChooser (too late)
    view.setEGLContextClientVersion(2);
    view.setFocusableInTouchMode(true);
    view.setFocusable(true);
    // setFormat must be set before AndroidConfigChooser is called by the surfaceview.
    // if setFormat is called after ConfigChooser is called, then execution
    // stops at the setFormat call without a crash.
    // We look at the user setting for alpha bits and set the surfaceview
    // PixelFormat to either Opaque, Transparent, or Translucent.
    // ConfigChooser will do it's best to honor the alpha requested by the user
    // For best rendering performance, use Opaque (alpha bits = 0).
    int curAlphaBits = settings.getAlphaBits();
    logger.log(Level.FINE, "curAlphaBits: {0}", curAlphaBits);
    if (curAlphaBits >= 8) {
        logger.log(Level.FINE, "Pixel Format: TRANSLUCENT");
        view.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        view.setZOrderOnTop(true);
    } else if (curAlphaBits >= 1) {
        logger.log(Level.FINE, "Pixel Format: TRANSPARENT");
        view.getHolder().setFormat(PixelFormat.TRANSPARENT);
    } else {
        logger.log(Level.FINE, "Pixel Format: OPAQUE");
        view.getHolder().setFormat(PixelFormat.OPAQUE);
    }
    AndroidConfigChooser configChooser = new AndroidConfigChooser(settings);
    view.setEGLConfigChooser(configChooser);
    view.setRenderer(this);
    // reloading all the OpenGL objects.
    if (Build.VERSION.SDK_INT >= 11) {
        view.setPreserveEGLContextOnPause(true);
    }
    return view;
}
Also used : AndroidInputHandler(com.jme3.input.android.AndroidInputHandler) AndroidInputHandler14(com.jme3.input.android.AndroidInputHandler14) ActivityManager(android.app.ActivityManager) GLSurfaceView(android.opengl.GLSurfaceView) ConfigurationInfo(android.content.pm.ConfigurationInfo)

Example 4 with ConfigurationInfo

use of android.content.pm.ConfigurationInfo in project android-gpuimage-ndkbuild-sample by mugku.

the class GPUImage method supportsOpenGLES2.

/**
     * Checks if OpenGL ES 2.0 is supported on the current device.
     *
     * @param context the context
     * @return true, if successful
     */
private boolean supportsOpenGLES2(final Context context) {
    final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    return configurationInfo.reqGlEsVersion >= 0x20000;
}
Also used : ActivityManager(android.app.ActivityManager) ConfigurationInfo(android.content.pm.ConfigurationInfo)

Example 5 with ConfigurationInfo

use of android.content.pm.ConfigurationInfo in project platform_frameworks_base by android.

the class ActivityManagerTest method testGetDeviceConfigurationInfo.

@SmallTest
public void testGetDeviceConfigurationInfo() throws Exception {
    ConfigurationInfo config = mActivityManager.getDeviceConfigurationInfo();
    assertNotNull(config);
    // Validate values against configuration retrieved from resources
    Configuration vconfig = mContext.getResources().getConfiguration();
    assertNotNull(vconfig);
    assertEquals(config.reqKeyboardType, vconfig.keyboard);
    assertEquals(config.reqTouchScreen, vconfig.touchscreen);
    assertEquals(config.reqNavigation, vconfig.navigation);
    if (vconfig.navigation == Configuration.NAVIGATION_NONAV) {
        assertNotNull(config.reqInputFeatures & ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV);
    }
    if (vconfig.keyboard != Configuration.KEYBOARD_UNDEFINED) {
        assertNotNull(config.reqInputFeatures & ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD);
    }
}
Also used : Configuration(android.content.res.Configuration) ConfigurationInfo(android.content.pm.ConfigurationInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ConfigurationInfo (android.content.pm.ConfigurationInfo)34 ActivityManager (android.app.ActivityManager)16 Parcel (android.os.Parcel)8 Configuration (android.content.res.Configuration)6 SmallTest (android.test.suitebuilder.annotation.SmallTest)6 Context (android.content.Context)2 GLSurfaceView (android.opengl.GLSurfaceView)1 View (android.view.View)1 AndroidInputHandler (com.jme3.input.android.AndroidInputHandler)1 AndroidInputHandler14 (com.jme3.input.android.AndroidInputHandler14)1 StarWarsRenderer (com.yalantis.starwars.render.StarWarsRenderer)1 StarWarsTilesGLSurfaceView (com.yalantis.starwars.widget.StarWarsTilesGLSurfaceView)1 ParticleSystemRenderer (com.yalantis.starwarsdemo.particlesys.ParticleSystemRenderer)1 BezierRenderer (com.yalantis.waves.gl.BezierRenderer)1