diff options
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher2/WallpaperChooser.java | 49 |
2 files changed, 7 insertions, 57 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index c45acb3f6..661fbdb77 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -21,9 +21,9 @@ import android.app.AlertDialog; import android.app.Application; import android.app.Dialog; import android.app.ISearchManager; -import android.app.IWallpaperService; import android.app.SearchManager; import android.app.StatusBarManager; +import android.app.WallpaperManager; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -40,13 +40,11 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.Bitmap; -import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; import android.os.Bundle; import android.os.Handler; -import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.MessageQueue; @@ -69,8 +67,6 @@ import android.view.ViewGroup; import android.view.View.OnLongClickListener; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; -import android.widget.GridView; -import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import android.appwidget.AppWidgetManager; @@ -349,19 +345,14 @@ public final class Launcher extends Activity implements View.OnClickListener, On } private void setWallpaperDimension() { - IBinder binder = ServiceManager.getService(WALLPAPER_SERVICE); - IWallpaperService wallpaperService = IWallpaperService.Stub.asInterface(binder); + WallpaperManager wpm = (WallpaperManager)getSystemService(WALLPAPER_SERVICE); Display display = getWindowManager().getDefaultDisplay(); boolean isPortrait = display.getWidth() < display.getHeight(); final int width = isPortrait ? display.getWidth() : display.getHeight(); final int height = isPortrait ? display.getHeight() : display.getWidth(); - try { - wallpaperService.setDimensionHints(width * WALLPAPER_SCREENS_SPAN, height); - } catch (RemoteException e) { - // System is dead! - } + wpm.setDimensionHints(width * WALLPAPER_SCREENS_SPAN, height); } @Override diff --git a/src/com/android/launcher2/WallpaperChooser.java b/src/com/android/launcher2/WallpaperChooser.java index 02e85eef5..4517bf5bc 100644 --- a/src/com/android/launcher2/WallpaperChooser.java +++ b/src/com/android/launcher2/WallpaperChooser.java @@ -17,15 +17,12 @@ package com.android.launcher2; import android.app.Activity; -import android.app.IWallpaperService; +import android.app.WallpaperManager; import android.content.res.Resources; import android.graphics.BitmapFactory; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.os.ParcelFileDescriptor; -import android.os.RemoteException; -import android.os.ServiceManager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -39,8 +36,6 @@ import android.widget.Gallery; import android.widget.ImageView; import java.io.IOException; -import java.io.InputStream; -import java.io.FileOutputStream; import java.util.ArrayList; import java.util.Collections; @@ -90,7 +85,6 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele private ArrayList<Integer> mThumbs; private ArrayList<Integer> mImages; - private ArrayList<String> mNames; @Override public void onCreate(Bundle icicle) { @@ -125,11 +119,6 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele final Resources resources = getResources(); - mNames = new ArrayList<String>(IMAGE_IDS.length + 4); - for (int res: mImages) { - mNames.add("res:" + resources.getResourceName(res)); - } - final String[] extras = resources.getStringArray(R.array.extra_wallpapers); final String packageName = getApplication().getPackageName(); @@ -142,7 +131,6 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele if (thumbRes != 0) { mThumbs.add(thumbRes); mImages.add(res); - mNames.add("res:" + extra); } } } @@ -182,8 +170,9 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele mIsWallpaperSet = true; try { - InputStream stream = getResources().openRawResource(mImages.get(position)); - setWallpaper(stream, mNames.get(position)); + WallpaperManager wpm = (WallpaperManager)getSystemService( + WALLPAPER_SERVICE); + wpm.set(mImages.get(position)); setResult(RESULT_OK); finish(); } catch (IOException e) { @@ -231,34 +220,4 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele public void onClick(View v) { selectWallpaper(mGallery.getSelectedItemPosition()); } - - private void setWallpaper(InputStream data, String name) throws IOException { - try { - IWallpaperService svc = IWallpaperService.Stub.asInterface( - ServiceManager.getService(WALLPAPER_SERVICE)); - ParcelFileDescriptor fd = svc.setWallpaper(name); - if (fd == null) { - return; - } - FileOutputStream fos = null; - try { - fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd); - setWallpaper(data, fos); - } finally { - if (fos != null) { - fos.close(); - } - } - } catch (RemoteException e) { - } - } - - private void setWallpaper(InputStream data, FileOutputStream fos) - throws IOException { - byte[] buffer = new byte[32768]; - int amt; - while ((amt=data.read(buffer)) > 0) { - fos.write(buffer, 0, amt); - } - } } |