Merge "Add new attributes for wallpaper info" into nyc-mr1-dev

This commit is contained in:
TreeHugger Robot
2016-06-04 00:22:05 +00:00
committed by Android (Google) Code Review
11 changed files with 145 additions and 18 deletions

View File

@@ -420,7 +420,9 @@ package android {
field public static final int contentInsetStart = 16843859; // 0x1010453
field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522
field public static final int contextClickable = 16844007; // 0x10104e7
field public static final int contextDescription = 16844082; // 0x1010532
field public static final int contextPopupMenuStyle = 16844033; // 0x1010501
field public static final int contextUri = 16844081; // 0x1010531
field public static final int controlX1 = 16843772; // 0x10103fc
field public static final int controlX2 = 16843774; // 0x10103fe
field public static final int controlY1 = 16843773; // 0x10103fd
@@ -1120,6 +1122,7 @@ package android {
field public static final int showDefault = 16843258; // 0x10101fa
field public static final int showDividers = 16843561; // 0x1010329
field public static final int showForAllUsers = 16844015; // 0x10104ef
field public static final int showMetadataInPreview = 16844083; // 0x1010533
field public static final deprecated int showOnLockScreen = 16843721; // 0x10103c9
field public static final int showSilent = 16843259; // 0x10101fb
field public static final int showText = 16843949; // 0x10104ad
@@ -5765,7 +5768,10 @@ package android.app {
method public android.content.pm.ServiceInfo getServiceInfo();
method public java.lang.String getServiceName();
method public java.lang.String getSettingsActivity();
method public boolean getShowMetadataInPreview();
method public java.lang.CharSequence loadAuthor(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public java.lang.CharSequence loadContextDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public android.net.Uri loadContextUri(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager);

View File

@@ -526,7 +526,9 @@ package android {
field public static final int contentInsetStart = 16843859; // 0x1010453
field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522
field public static final int contextClickable = 16844007; // 0x10104e7
field public static final int contextDescription = 16844082; // 0x1010532
field public static final int contextPopupMenuStyle = 16844033; // 0x1010501
field public static final int contextUri = 16844081; // 0x1010531
field public static final int controlX1 = 16843772; // 0x10103fc
field public static final int controlX2 = 16843774; // 0x10103fe
field public static final int controlY1 = 16843773; // 0x10103fd
@@ -1230,6 +1232,7 @@ package android {
field public static final int showDefault = 16843258; // 0x10101fa
field public static final int showDividers = 16843561; // 0x1010329
field public static final int showForAllUsers = 16844015; // 0x10104ef
field public static final int showMetadataInPreview = 16844083; // 0x1010533
field public static final deprecated int showOnLockScreen = 16843721; // 0x10103c9
field public static final int showSilent = 16843259; // 0x10101fb
field public static final int showText = 16843949; // 0x10104ad
@@ -5912,7 +5915,10 @@ package android.app {
method public android.content.pm.ServiceInfo getServiceInfo();
method public java.lang.String getServiceName();
method public java.lang.String getSettingsActivity();
method public boolean getShowMetadataInPreview();
method public java.lang.CharSequence loadAuthor(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public java.lang.CharSequence loadContextDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public android.net.Uri loadContextUri(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager);

View File

@@ -420,7 +420,9 @@ package android {
field public static final int contentInsetStart = 16843859; // 0x1010453
field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522
field public static final int contextClickable = 16844007; // 0x10104e7
field public static final int contextDescription = 16844082; // 0x1010532
field public static final int contextPopupMenuStyle = 16844033; // 0x1010501
field public static final int contextUri = 16844081; // 0x1010531
field public static final int controlX1 = 16843772; // 0x10103fc
field public static final int controlX2 = 16843774; // 0x10103fe
field public static final int controlY1 = 16843773; // 0x10103fd
@@ -1120,6 +1122,7 @@ package android {
field public static final int showDefault = 16843258; // 0x10101fa
field public static final int showDividers = 16843561; // 0x1010329
field public static final int showForAllUsers = 16844015; // 0x10104ef
field public static final int showMetadataInPreview = 16844083; // 0x1010533
field public static final deprecated int showOnLockScreen = 16843721; // 0x10103c9
field public static final int showSilent = 16843259; // 0x10101fb
field public static final int showText = 16843949; // 0x10104ad
@@ -5771,7 +5774,10 @@ package android.app {
method public android.content.pm.ServiceInfo getServiceInfo();
method public java.lang.String getServiceName();
method public java.lang.String getSettingsActivity();
method public boolean getShowMetadataInPreview();
method public java.lang.CharSequence loadAuthor(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public java.lang.CharSequence loadContextDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public android.net.Uri loadContextUri(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager);

View File

@@ -31,6 +31,7 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.service.wallpaper.WallpaperService;
@@ -72,6 +73,10 @@ public final class WallpaperInfo implements Parcelable {
*/
final int mDescriptionResource;
final int mContextUriResource;
final int mContextDescriptionResource;
final boolean mShowMetadataInPreview;
/**
* Constructor.
*
@@ -89,7 +94,10 @@ public final class WallpaperInfo implements Parcelable {
int thumbnailRes = -1;
int authorRes = -1;
int descriptionRes = -1;
int contextUriRes = -1;
int contextDescriptionRes = -1;
boolean showMetadataInPreview = false;
XmlResourceParser parser = null;
try {
parser = si.loadXmlMetaData(pm, WallpaperService.SERVICE_META_DATA);
@@ -127,6 +135,15 @@ public final class WallpaperInfo implements Parcelable {
descriptionRes = sa.getResourceId(
com.android.internal.R.styleable.Wallpaper_description,
-1);
contextUriRes = sa.getResourceId(
com.android.internal.R.styleable.Wallpaper_contextUri,
-1);
contextDescriptionRes = sa.getResourceId(
com.android.internal.R.styleable.Wallpaper_contextDescription,
-1);
showMetadataInPreview = sa.getBoolean(
com.android.internal.R.styleable.Wallpaper_showMetadataInPreview,
false);
sa.recycle();
} catch (NameNotFoundException e) {
@@ -140,6 +157,9 @@ public final class WallpaperInfo implements Parcelable {
mThumbnailResource = thumbnailRes;
mAuthorResource = authorRes;
mDescriptionResource = descriptionRes;
mContextUriResource = contextUriRes;
mContextDescriptionResource = contextDescriptionRes;
mShowMetadataInPreview = showMetadataInPreview;
}
WallpaperInfo(Parcel source) {
@@ -147,6 +167,9 @@ public final class WallpaperInfo implements Parcelable {
mThumbnailResource = source.readInt();
mAuthorResource = source.readInt();
mDescriptionResource = source.readInt();
mContextUriResource = source.readInt();
mContextDescriptionResource = source.readInt();
mShowMetadataInPreview = source.readInt() != 0;
mService = ResolveInfo.CREATOR.createFromParcel(source);
}
@@ -248,7 +271,55 @@ public final class WallpaperInfo implements Parcelable {
return pm.getText(packageName, mDescriptionResource,
mService.serviceInfo.applicationInfo);
}
/**
* Returns an URI that specifies a link for further context about this wallpaper.
*
* @param pm An instance of {@link PackageManager} to retrieve the URI.
* @return The URI.
*/
public Uri loadContextUri(PackageManager pm) throws NotFoundException {
if (mContextUriResource <= 0) throw new NotFoundException();
String packageName = mService.resolvePackageName;
ApplicationInfo applicationInfo = null;
if (packageName == null) {
packageName = mService.serviceInfo.packageName;
applicationInfo = mService.serviceInfo.applicationInfo;
}
String contextUriString = pm.getText(
packageName, mContextUriResource, applicationInfo).toString();
if (contextUriString == null) {
return null;
}
return Uri.parse(contextUriString);
}
/**
* Retrieves a title of the URI that specifies a link for further context about this wallpaper.
*
* @param pm An instance of {@link PackageManager} to retrieve the title.
* @return The title.
*/
public CharSequence loadContextDescription(PackageManager pm) throws NotFoundException {
if (mContextDescriptionResource <= 0) throw new NotFoundException();
String packageName = mService.resolvePackageName;
ApplicationInfo applicationInfo = null;
if (packageName == null) {
packageName = mService.serviceInfo.packageName;
applicationInfo = mService.serviceInfo.applicationInfo;
}
return pm.getText(packageName, mContextDescriptionResource, applicationInfo).toString();
}
/**
* Queries whether any metadata should be shown when previewing the wallpaper.
*
* @return Whether any metadata should be shown when previewing the wallpaper.
*/
public boolean getShowMetadataInPreview() {
return mShowMetadataInPreview;
}
/**
* Return the class name of an activity that provides a settings UI for
* the wallpaper. You can launch this activity be starting it with
@@ -287,6 +358,9 @@ public final class WallpaperInfo implements Parcelable {
dest.writeInt(mThumbnailResource);
dest.writeInt(mAuthorResource);
dest.writeInt(mDescriptionResource);
dest.writeInt(mContextUriResource);
dest.writeInt(mContextDescriptionResource);
dest.writeInt(mShowMetadataInPreview ? 1 : 0);
mService.writeToParcel(dest, flags);
}

View File

@@ -55,6 +55,7 @@ import android.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManagerGlobal;
import java.io.FileDescriptor;
@@ -628,9 +629,9 @@ public abstract class WallpaperService extends Service {
mCurWindowFlags = mWindowFlags;
mLayout.flags = mWindowFlags
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
;
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
mCurWindowPrivateFlags = mWindowPrivateFlags;
mLayout.privateFlags = mWindowPrivateFlags;

View File

@@ -7335,14 +7335,24 @@ i
<declare-styleable name="Wallpaper">
<attr name="settingsActivity" />
<!-- Reference to a the wallpaper's thumbnail bitmap. -->
<!-- Reference to the wallpaper's thumbnail bitmap. -->
<attr name="thumbnail" format="reference" />
<!-- Name of the author of this component, e.g. Google. -->
<!-- Name of the author and/or source/collection of this component, e.g. Art Collection, Picasso. -->
<attr name="author" format="reference" />
<!-- Short description of the component's purpose or behavior. -->
<attr name="description" />
<!-- Uri that specifies a link for further context of this wallpaper, e.g. http://www.picasso.org. -->
<attr name="contextUri" format="reference" />
<!-- Title of the uri that specifies a link for further context of this wallpaper, e.g. Explore collection. -->
<attr name="contextDescription" format="reference" />
<!-- Whether to show any metadata when previewing the wallpaper. -->
<attr name="showMetadataInPreview" format="boolean" />
</declare-styleable>
<!-- Use <code>dream</code> as the root tag of the XML resource that

View File

@@ -2741,4 +2741,9 @@
<public type="attr" name="shortcutIntentAction" />
<public type="attr" name="shortcutIntentData" />
<public type="attr" name="roundIcon" />
<public type="attr" name="contextUri" />
<public type="attr" name="contextDescription" />
<public type="attr" name="showMetadataInPreview" />
</resources>

View File

@@ -4392,6 +4392,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} else {
vf.set(cf);
}
} else if (attrs.type == TYPE_WALLPAPER) {
layoutWallpaper(win, pf, df, of, cf);
} else if (win == mStatusBar) {
pf.left = df.left = of.left = mUnrestrictedScreenLeft;
pf.top = df.top = of.top = mUnrestrictedScreenTop;
@@ -4615,17 +4617,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
+ mOverscanScreenWidth;
pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop
+ mOverscanScreenHeight;
} else if (attrs.type == TYPE_WALLPAPER) {
// The wallpaper also has Real Ultimate Power, but we want to tell
// it about the overscan area.
pf.left = df.left = mOverscanScreenLeft;
pf.top = df.top = mOverscanScreenTop;
pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth;
pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight;
of.left = cf.left = mUnrestrictedScreenLeft;
of.top = cf.top = mUnrestrictedScreenTop;
of.right = cf.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
of.bottom = cf.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
} else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0
&& attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
&& attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
@@ -4818,6 +4809,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
private void layoutWallpaper(WindowState win, Rect pf, Rect df, Rect of, Rect cf) {
// The wallpaper also has Real Ultimate Power, but we want to tell
// it about the overscan area.
pf.left = df.left = mOverscanScreenLeft;
pf.top = df.top = mOverscanScreenTop;
pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth;
pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight;
of.left = cf.left = mUnrestrictedScreenLeft;
of.top = cf.top = mUnrestrictedScreenTop;
of.right = cf.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
of.bottom = cf.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
}
private void offsetInputMethodWindowLw(WindowState win) {
int top = Math.max(win.getDisplayFrameLw().top, win.getContentFrameLw().top);
top += win.getGivenContentInsetsLw().top;

View File

@@ -24,6 +24,9 @@ limitations under the License.
Test wallpaper for use with the wallpaper test app.
</string>
<string name="test_wallpaper_context_uri">https://www.google.com/maps/@37.8092876,-122.408986,1391m/data=!3m1!1e3</string>
<string name="test_wallpaper_context_description">Explore</string>
<string name="dimens">Dimens: </string>
<string name="width">Width: </string>
<string name="height">Height: </string>

View File

@@ -23,4 +23,7 @@
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:author="@string/test_wallpaper_author"
android:description="@string/test_wallpaper_desc"
android:thumbnail="@drawable/test_wallpaper_thumb" />
android:thumbnail="@drawable/test_wallpaper_thumb"
android:showMetadataInPreview="true"
android:contextUri="@string/test_wallpaper_context_uri"
android:contextDescription="@string/test_wallpaper_context_description"/>

View File

@@ -144,6 +144,14 @@ public class TestWallpaper extends WallpaperService {
@Override
public void onSurfaceCreated(SurfaceHolder holder) {
super.onSurfaceCreated(holder);
// Simulate some slowness, so we can test the loading process in the live wallpaper
// picker.
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override