Пример #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
 void doCommand(WallpaperCommand cmd) {
   Bundle result;
   if (!mDestroyed) {
     result = onCommand(cmd.action, cmd.x, cmd.y, cmd.z, cmd.extras, cmd.sync);
   } else {
     result = null;
   }
   if (cmd.sync) {
     try {
       if (DEBUG) Log.v(TAG, "Reporting command complete");
       mSession.wallpaperCommandComplete(mWindow.asBinder(), result);
     } catch (RemoteException e) {
     }
   }
 }
Пример #3
0
    void doOffsetsChanged(boolean always) {
      if (mDestroyed) {
        return;
      }

      if (!always && !mOffsetsChanged) {
        return;
      }

      float xOffset;
      float yOffset;
      float xOffsetStep;
      float yOffsetStep;
      boolean sync;
      synchronized (mLock) {
        xOffset = mPendingXOffset;
        yOffset = mPendingYOffset;
        xOffsetStep = mPendingXOffsetStep;
        yOffsetStep = mPendingYOffsetStep;
        sync = mPendingSync;
        mPendingSync = false;
        mOffsetMessageEnqueued = false;
      }

      if (mSurfaceCreated) {
        if (mReportedVisible) {
          if (DEBUG) Log.v(TAG, "Offsets change in " + this + ": " + xOffset + "," + yOffset);
          final int availw = mIWallpaperEngine.mReqWidth - mCurWidth;
          final int xPixels = availw > 0 ? -(int) (availw * xOffset + .5f) : 0;
          final int availh = mIWallpaperEngine.mReqHeight - mCurHeight;
          final int yPixels = availh > 0 ? -(int) (availh * yOffset + .5f) : 0;
          onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixels, yPixels);
        } else {
          mOffsetsChanged = true;
        }
      }

      if (sync) {
        try {
          if (DEBUG) Log.v(TAG, "Reporting offsets change complete");
          mSession.wallpaperOffsetsComplete(mWindow.asBinder());
        } catch (RemoteException e) {
        }
      }
    }