コード例 #1
0
    void attach(IWallpaperEngineWrapper wrapper) {
      if (DEBUG) Log.v(TAG, "attach: " + this + " wrapper=" + wrapper);
      if (mDestroyed) {
        return;
      }

      mIWallpaperEngine = wrapper;
      mCaller = wrapper.mCaller;
      mConnection = wrapper.mConnection;
      mWindowToken = wrapper.mWindowToken;
      mSurfaceHolder.setSizeFromLayout();
      mInitializing = true;
      mSession = WindowManagerGlobal.getWindowSession(getMainLooper());

      mWindow.setSession(mSession);

      mScreenOn = ((PowerManager) getSystemService(Context.POWER_SERVICE)).isScreenOn();

      IntentFilter filter = new IntentFilter();
      filter.addAction(Intent.ACTION_SCREEN_ON);
      filter.addAction(Intent.ACTION_SCREEN_OFF);
      registerReceiver(mReceiver, filter);

      if (DEBUG) Log.v(TAG, "onCreate(): " + this);
      onCreate(mSurfaceHolder);

      mInitializing = false;
      mReportedVisible = false;
      updateSurface(false, false, false);
    }
コード例 #2
0
 /**
  * Control whether this wallpaper will receive raw touch events from the window manager as the
  * user interacts with the window that is currently displaying the wallpaper. By default they
  * are turned off. If enabled, the events will be received in {@link
  * #onTouchEvent(MotionEvent)}.
  */
 public void setTouchEventsEnabled(boolean enabled) {
   mWindowFlags =
       enabled
           ? (mWindowFlags & ~WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
           : (mWindowFlags | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
   if (mCreated) {
     updateSurface(false, false, false);
   }
 }
コード例 #3
0
 /**
  * Control whether this wallpaper will receive notifications when the wallpaper has been
  * scrolled. By default, wallpapers will receive notifications, although the default static
  * image wallpapers do not. It is a performance optimization to set this to false.
  *
  * @param enabled whether the wallpaper wants to receive offset notifications
  */
 public void setOffsetNotificationsEnabled(boolean enabled) {
   mWindowPrivateFlags =
       enabled
           ? (mWindowPrivateFlags
               | WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS)
           : (mWindowPrivateFlags
               & ~WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS);
   if (mCreated) {
     updateSurface(false, false, false);
   }
 }
コード例 #4
0
 void reportVisibility() {
   if (!mDestroyed) {
     boolean visible = mVisible && mScreenOn;
     if (mReportedVisible != visible) {
       mReportedVisible = visible;
       if (DEBUG) Log.v(TAG, "onVisibilityChanged(" + visible + "): " + this);
       if (visible) {
         // If becoming visible, in preview mode the surface
         // may have been destroyed so now we need to make
         // sure it is re-created.
         doOffsetsChanged(false);
         updateSurface(false, false, false);
       }
       onVisibilityChanged(visible);
     }
   }
 }