diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-09-07 00:49:58 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-09-07 22:48:02 -0700 |
commit | eb034652c2037a47ebfd99779e8383bb8bb528af (patch) | |
tree | 0d4f6d9b752d6be70083cdf51085872e52610c3b /services | |
parent | 9c93007bcdf684cd15fd9db0cf1eae238dd38191 (diff) | |
download | frameworks_base-eb034652c2037a47ebfd99779e8383bb8bb528af.zip frameworks_base-eb034652c2037a47ebfd99779e8383bb8bb528af.tar.gz frameworks_base-eb034652c2037a47ebfd99779e8383bb8bb528af.tar.bz2 |
Implement all of the infrastructure for configuring wallpapers.
Actually being able to configure a wallpaper relies on additional
work in the launcher and wallpapers that will be in another change.
Also note that this breaks all existing wallpapers, since they now
need to include a meta-data item about themselves. This also
will be fixed in another change.
Change-Id: I97d2c2bd07237abc32f92b9147c32530a2f73c71
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/WallpaperManagerService.java | 81 | ||||
-rw-r--r-- | services/java/com/android/server/am/ActivityManagerService.java | 1 |
2 files changed, 71 insertions, 11 deletions
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java index cc977b0..4b6049f 100644 --- a/services/java/com/android/server/WallpaperManagerService.java +++ b/services/java/com/android/server/WallpaperManagerService.java @@ -22,6 +22,7 @@ import static android.os.ParcelFileDescriptor.*; import android.app.IWallpaperManager; import android.app.IWallpaperManagerCallback; import android.app.PendingIntent; +import android.app.WallpaperInfo; import android.backup.BackupManager; import android.content.ComponentName; import android.content.Context; @@ -41,7 +42,6 @@ import android.os.ParcelFileDescriptor; import android.os.RemoteCallbackList; import android.os.ServiceManager; import android.os.SystemClock; -import android.provider.Settings; import android.service.wallpaper.IWallpaperConnection; import android.service.wallpaper.IWallpaperEngine; import android.service.wallpaper.IWallpaperService; @@ -51,12 +51,14 @@ import android.util.Xml; import android.view.IWindowManager; import android.view.WindowManager; +import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.PrintWriter; import java.util.List; import org.xmlpull.v1.XmlPullParser; @@ -130,15 +132,25 @@ class WallpaperManagerService extends IWallpaperManager.Stub { class WallpaperConnection extends IWallpaperConnection.Stub implements ServiceConnection { + final WallpaperInfo mInfo; final Binder mToken = new Binder(); IWallpaperService mService; IWallpaperEngine mEngine; + public WallpaperConnection(WallpaperInfo info) { + mInfo = info; + } + public void onServiceConnected(ComponentName name, IBinder service) { synchronized (mLock) { if (mWallpaperConnection == this) { mService = IWallpaperService.Stub.asInterface(service); attachServiceLocked(this); + // XXX should probably do saveSettingsLocked() later + // when we have an engine, but I'm not sure about + // locking there and anyway we always need to be able to + // recover if there is something wrong. + saveSettingsLocked(); } } } @@ -165,11 +177,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { public ParcelFileDescriptor setWallpaper(String name) { synchronized (mLock) { if (mWallpaperConnection == this) { - ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name); - if (pfd != null) { - saveSettingsLocked(); - } - return pfd; + return updateWallpaperBitmapLocked(name); } return null; } @@ -283,6 +291,15 @@ class WallpaperManagerService extends IWallpaperManager.Stub { } } + public WallpaperInfo getWallpaperInfo() { + synchronized (mLock) { + if (mWallpaperConnection != null) { + return mWallpaperConnection.mInfo; + } + return null; + } + } + public ParcelFileDescriptor setWallpaper(String name) { checkPermission(android.Manifest.permission.SET_WALLPAPER); synchronized (mLock) { @@ -356,32 +373,43 @@ class WallpaperManagerService extends IWallpaperManager.Stub { + ": " + realName); } + WallpaperInfo wi = null; + Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE); if (name != null) { // Make sure the selected service is actually a wallpaper service. List<ResolveInfo> ris = mContext.getPackageManager() - .queryIntentServices(intent, 0); + .queryIntentServices(intent, PackageManager.GET_META_DATA); for (int i=0; i<ris.size(); i++) { ServiceInfo rsi = ris.get(i).serviceInfo; if (rsi.name.equals(si.name) && rsi.packageName.equals(si.packageName)) { - ris = null; + try { + wi = new WallpaperInfo(mContext, ris.get(i)); + } catch (XmlPullParserException e) { + throw new IllegalArgumentException(e); + } catch (IOException e) { + throw new IllegalArgumentException(e); + } break; } } - if (ris != null) { + if (wi == null) { throw new SecurityException("Selected service is not a wallpaper: " + realName); } } // Bind the service! - WallpaperConnection newConn = new WallpaperConnection(); + WallpaperConnection newConn = new WallpaperConnection(wi); intent.setComponent(realName); intent.putExtra(Intent.EXTRA_CLIENT_LABEL, com.android.internal.R.string.wallpaper_binding_label); intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity( - mContext, 0, new Intent(Intent.ACTION_SET_WALLPAPER), 0)); + mContext, 0, + Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER), + mContext.getText(com.android.internal.R.string.chooser_wallpaper)), + 0)); if (!mContext.bindService(intent, newConn, Context.BIND_AUTO_CREATE)) { throw new IllegalArgumentException("Unable to bind service: " @@ -640,4 +668,35 @@ class WallpaperManagerService extends IWallpaperManager.Stub { } return false; } + + @Override + protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) + != PackageManager.PERMISSION_GRANTED) { + + pw.println("Permission Denial: can't dump wallpaper service from from pid=" + + Binder.getCallingPid() + + ", uid=" + Binder.getCallingUid()); + return; + } + + synchronized (mLock) { + pw.println("Current Wallpaper Service state:"); + pw.print(" mWidth="); pw.print(mWidth); + pw.print(" mHeight="); pw.println(mHeight); + pw.print(" mName="); pw.println(mName); + pw.print(" mWallpaperComponent="); pw.println(mWallpaperComponent); + if (mWallpaperConnection != null) { + WallpaperConnection conn = mWallpaperConnection; + pw.print(" Wallpaper connection "); + pw.print(conn); pw.println(":"); + pw.print(" mInfo.component="); pw.println(conn.mInfo.getComponent()); + pw.print(" mToken="); pw.println(conn.mToken); + pw.print(" mService="); pw.println(conn.mService); + pw.print(" mEngine="); pw.println(conn.mEngine); + pw.print(" mLastDiedTime="); + pw.println(mLastDiedTime - SystemClock.uptimeMillis()); + } + } + } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index badfa30..0b86fc0 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -8855,6 +8855,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen ActivityManager.RunningAppProcessInfo currApp = new ActivityManager.RunningAppProcessInfo(app.processName, app.pid, app.getPackageList()); + currApp.uid = app.info.uid; int adj = app.curAdj; if (adj >= CONTENT_PROVIDER_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY; |