コード例 #1
0
 public void insertScreenSettingInfo(ScreenSettingInfo info) {
   final DataProvider dataProvider = mDataProvider;
   ContentValues values = new ContentValues();
   info.contentValues(values);
   dataProvider.insertScreenSetting(values);
   values = null;
 }
コード例 #2
0
 // 屏幕设置
 public ScreenSettingInfo getScreenSettingInfo() {
   final DataProvider dataProvider = mDataProvider;
   Cursor cursor = dataProvider.queryScreenSetting();
   if (null != cursor) {
     try {
       ScreenSettingInfo info = new ScreenSettingInfo();
       boolean bOk = info.parseFromCursor(cursor);
       if (bOk) {
         return info;
       }
     } catch (SQLiteException e) {
       e.printStackTrace();
     } finally {
       cursor.close();
     }
   }
   return null;
 }
コード例 #3
0
  /**
   * 调整壁纸尺寸的方法,只要是针对壁纸放大的问题(用户当前是可滚,但是选择壁纸时却是单屏,这时候设回为单屏)
   *
   * @param wallpaperManager
   * @return
   */
  public static boolean adjustWallpaperDimension(WallpaperManager wallpaperManager) {
    // 是否进行调整的结果
    boolean result = false;
    if (wallpaperManager == null) {
      wallpaperManager = WallpaperManager.getInstance(GOLauncherApp.getContext());
    }
    try {
      Method method = wallpaperManager.getClass().getMethod("getIWallpaperManager");
      Object iWallpaperManager = method.invoke(wallpaperManager);
      // Class IWallpaperManager = iWallpaperManager.getClass();
      Class iWallpaperManagerClass = Class.forName("android.app.IWallpaperManager");

      Field field = wallpaperManager.getClass().getDeclaredField("sGlobals");
      field.setAccessible(true);
      Object globals = field.get(wallpaperManager);

      Class[] arrayOfClass =
          new Class[] {Class.forName("android.app.IWallpaperManagerCallback"), Bundle.class};
      method = iWallpaperManagerClass.getDeclaredMethod("getWallpaper", arrayOfClass);
      method.setAccessible(true);

      Bundle params = new Bundle();
      ParcelFileDescriptor fd =
          (ParcelFileDescriptor) method.invoke(iWallpaperManager, new Object[] {globals, params});

      if (fd != null) {
        final int width = params.getInt("width", 0);
        final int height = params.getInt("height", 0);
        try {
          BitmapFactory.Options options = new BitmapFactory.Options();
          Bitmap bm = BitmapFactory.decodeFileDescriptor(fd.getFileDescriptor(), null, options);
          final int bitWidth = bm.getWidth();
          final int bitHeight = bm.getHeight();
          GoSettingControler settingControler = GOLauncherApp.getSettingControler();
          ScreenSettingInfo screenSettingInfo =
              GOLauncherApp.getSettingControler().getScreenSettingInfo();

          if (bitWidth == width / 2 && screenSettingInfo.mWallpaperScroll) {
            screenSettingInfo.mWallpaperScroll = false;
            result = true;
          }
          // else if(bitWidth == width * 2 &&
          // !screenSettingInfo.mWallpaperScroll){
          // screenSettingInfo.mWallpaperScroll = true;
          // result = true;
          // }
          if (result) {
            // 把屏幕是否可滚写进数据库
            settingControler.updateScreenSettingInfo(screenSettingInfo, false);
            WallpaperDensityUtil.setWallpaperDimension(GoLauncher.getContext());
          }
        } catch (OutOfMemoryError e) {
          result = false;
        } finally {
          try {
            fd.close();
          } catch (IOException e) {
            result = false;
          }
        }
      }
    } catch (Throwable e) {
      Log.v("System.out.print", e.toString());
      result = false;
    }
    return result;
  } // end adjustWallpaperDimension