Advertisement
Guest User

BootAnimation.cpp ICS

a guest
Dec 8th, 2011
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.39 KB | None | 0 0
  1. status_t BootAnimation::readyToRun() {
  2.     mAssets.addDefaultAssets();
  3.  
  4.     DisplayInfo dinfo;
  5.     status_t status = session()->getDisplayInfo(0, &dinfo);
  6.     if (status)
  7.         return -1;
  8.  
  9.     // create the native surface
  10.     sp<SurfaceControl> control = session()->createSurface(
  11.             0, dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
  12.  
  13.     SurfaceComposerClient::openGlobalTransaction();
  14.     control->setLayer(0x40000000);
  15.     SurfaceComposerClient::closeGlobalTransaction();
  16.  
  17.     sp<Surface> s = control->getSurface();
  18.  
  19.     // initialize opengl and egl
  20.     const EGLint attribs[] = {
  21.             EGL_RED_SIZE,   8,
  22.             EGL_GREEN_SIZE, 8,
  23.             EGL_BLUE_SIZE,  8,
  24.             EGL_DEPTH_SIZE, 0,
  25.             EGL_NONE
  26.     };
  27.     EGLint w, h, dummy;
  28.     EGLint numConfigs;
  29.     EGLConfig config;
  30.     EGLSurface surface;
  31.     EGLContext context;
  32.  
  33.     EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  34.  
  35.     eglInitialize(display, 0, 0);
  36.     eglChooseConfig(display, attribs, &config, 1, &numConfigs);
  37.     surface = eglCreateWindowSurface(display, config, s.get(), NULL);
  38.     context = eglCreateContext(display, config, NULL, NULL);
  39.     eglQuerySurface(display, surface, EGL_WIDTH, &w);
  40.     eglQuerySurface(display, surface, EGL_HEIGHT, &h);
  41.  
  42.     if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
  43.         return NO_INIT;
  44.  
  45.     mDisplay = display;
  46.     mContext = context;
  47.     mSurface = surface;
  48.     mWidth = w;
  49.     mHeight = h;
  50.     mFlingerSurfaceControl = control;
  51.     mFlingerSurface = s;
  52.  
  53.     mAndroidAnimation = true;
  54.  
  55.     // If the device has encryption turned on or is in process
  56.     // of being encrypted we show the encrypted boot animation.
  57.     char decrypt[PROPERTY_VALUE_MAX];
  58.     property_get("vold.decrypt", decrypt, "");
  59.  
  60.     bool encryptedAnimation = atoi(decrypt) != 0 || !strcmp("trigger_restart_min_framework", decrypt);
  61.  
  62.     if ((encryptedAnimation &&
  63.             (access(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE, R_OK) == 0) &&
  64.             (mZip.open(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE) == NO_ERROR)) ||
  65.  
  66.             ((access(USER_BOOTANIMATION_FILE, R_OK) == 0) &&
  67.             (mZip.open(USER_BOOTANIMATION_FILE) == NO_ERROR)) ||
  68.  
  69.             ((access(SYSTEM_BOOTANIMATION_FILE, R_OK) == 0) &&
  70.             (mZip.open(SYSTEM_BOOTANIMATION_FILE) == NO_ERROR))) {
  71.         mAndroidAnimation = false;
  72.     }
  73.  
  74.     return NO_ERROR;
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement