am 84fd4af0: Merge "Make DatePicker rendering not fail." into mnc-dev
* commit '84fd4af05353303750427b19ea20992694f864f8': Make DatePicker rendering not fail.
This commit is contained in:
@@ -16,8 +16,12 @@
|
|||||||
|
|
||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
|
import com.android.layoutlib.bridge.android.BridgeContext;
|
||||||
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
|
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.IBinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delegate used to provide new implementation of a select few methods of {@link View}
|
* Delegate used to provide new implementation of a select few methods of {@link View}
|
||||||
*
|
*
|
||||||
@@ -31,4 +35,13 @@ public class View_Delegate {
|
|||||||
/*package*/ static boolean isInEditMode(View thisView) {
|
/*package*/ static boolean isInEditMode(View thisView) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@LayoutlibDelegate
|
||||||
|
/*package*/ static IBinder getWindowToken(View thisView) {
|
||||||
|
Context baseContext = BridgeContext.getBaseContext(thisView.getContext());
|
||||||
|
if (baseContext instanceof BridgeContext) {
|
||||||
|
return ((BridgeContext) baseContext).getBinder();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,11 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.IInterface;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.os.Parcel;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
@@ -82,6 +85,7 @@ import android.view.accessibility.AccessibilityManager;
|
|||||||
import android.view.textservice.TextServicesManager;
|
import android.view.textservice.TextServicesManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileDescriptor;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@@ -139,6 +143,7 @@ public final class BridgeContext extends Context {
|
|||||||
private final Stack<BridgeXmlBlockParser> mParserStack = new Stack<BridgeXmlBlockParser>();
|
private final Stack<BridgeXmlBlockParser> mParserStack = new Stack<BridgeXmlBlockParser>();
|
||||||
private SharedPreferences mSharedPreferences;
|
private SharedPreferences mSharedPreferences;
|
||||||
private ClassLoader mClassLoader;
|
private ClassLoader mClassLoader;
|
||||||
|
private IBinder mBinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param projectKey An Object identifying the project. This is used for the cache mechanism.
|
* @param projectKey An Object identifying the project. This is used for the cache mechanism.
|
||||||
@@ -708,44 +713,48 @@ public final class BridgeContext extends Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (defStyleRes != 0) {
|
} else if (defStyleRes != 0) {
|
||||||
boolean isFrameworkRes = true;
|
StyleResourceValue item = mDynamicIdToStyleMap.get(defStyleRes);
|
||||||
Pair<ResourceType, String> value = Bridge.resolveResourceId(defStyleRes);
|
if (item != null) {
|
||||||
if (value == null) {
|
defStyleValues = item;
|
||||||
value = mLayoutlibCallback.resolveResourceId(defStyleRes);
|
} else {
|
||||||
isFrameworkRes = false;
|
boolean isFrameworkRes = true;
|
||||||
}
|
Pair<ResourceType, String> value = Bridge.resolveResourceId(defStyleRes);
|
||||||
|
if (value == null) {
|
||||||
|
value = mLayoutlibCallback.resolveResourceId(defStyleRes);
|
||||||
|
isFrameworkRes = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
if ((value.getFirst() == ResourceType.STYLE)) {
|
if ((value.getFirst() == ResourceType.STYLE)) {
|
||||||
// look for the style in all resources:
|
// look for the style in all resources:
|
||||||
StyleResourceValue item = mRenderResources.getStyle(value.getSecond(),
|
item = mRenderResources.getStyle(value.getSecond(), isFrameworkRes);
|
||||||
isFrameworkRes);
|
if (item != null) {
|
||||||
if (item != null) {
|
if (defaultPropMap != null) {
|
||||||
if (defaultPropMap != null) {
|
defaultPropMap.put("style", item.getName());
|
||||||
defaultPropMap.put("style", item.getName());
|
}
|
||||||
|
|
||||||
|
defStyleValues = item;
|
||||||
|
} else {
|
||||||
|
Bridge.getLog().error(null,
|
||||||
|
String.format(
|
||||||
|
"Style with id 0x%x (resolved to '%s') does not exist.",
|
||||||
|
defStyleRes, value.getSecond()),
|
||||||
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
defStyleValues = item;
|
|
||||||
} else {
|
} else {
|
||||||
Bridge.getLog().error(null,
|
Bridge.getLog().error(null,
|
||||||
String.format(
|
String.format(
|
||||||
"Style with id 0x%x (resolved to '%s') does not exist.",
|
"Resource id 0x%x is not of type STYLE (instead %s)",
|
||||||
defStyleRes, value.getSecond()),
|
defStyleRes, value.getFirst().toString()),
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Bridge.getLog().error(null,
|
Bridge.getLog().error(null,
|
||||||
String.format(
|
String.format(
|
||||||
"Resource id 0x%x is not of type STYLE (instead %s)",
|
"Failed to find style with id 0x%x in current theme",
|
||||||
defStyleRes, value.getFirst().toString()),
|
defStyleRes),
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Bridge.getLog().error(null,
|
|
||||||
String.format(
|
|
||||||
"Failed to find style with id 0x%x in current theme",
|
|
||||||
defStyleRes),
|
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -996,6 +1005,61 @@ public final class BridgeContext extends Context {
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IBinder getBinder() {
|
||||||
|
if (mBinder == null) {
|
||||||
|
// create a dummy binder. We only need it be not null.
|
||||||
|
mBinder = new IBinder() {
|
||||||
|
@Override
|
||||||
|
public String getInterfaceDescriptor() throws RemoteException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean pingBinder() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBinderAlive() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IInterface queryLocalInterface(String descriptor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dump(FileDescriptor fd, String[] args) throws RemoteException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dumpAsync(FileDescriptor fd, String[] args) throws RemoteException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transact(int code, Parcel data, Parcel reply, int flags)
|
||||||
|
throws RemoteException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void linkToDeath(DeathRecipient recipient, int flags)
|
||||||
|
throws RemoteException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean unlinkToDeath(DeathRecipient recipient, int flags) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return mBinder;
|
||||||
|
}
|
||||||
|
|
||||||
//------------ NOT OVERRIDEN --------------------
|
//------------ NOT OVERRIDEN --------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ public final class CreateInfo implements ICreateInfo {
|
|||||||
"android.view.Display#getWindowManager",
|
"android.view.Display#getWindowManager",
|
||||||
"android.view.LayoutInflater#rInflate",
|
"android.view.LayoutInflater#rInflate",
|
||||||
"android.view.LayoutInflater#parseInclude",
|
"android.view.LayoutInflater#parseInclude",
|
||||||
|
"android.view.View#getWindowToken",
|
||||||
"android.view.View#isInEditMode",
|
"android.view.View#isInEditMode",
|
||||||
"android.view.ViewRootImpl#isInTouchMode",
|
"android.view.ViewRootImpl#isInTouchMode",
|
||||||
"android.view.WindowManagerGlobal#getWindowManagerService",
|
"android.view.WindowManagerGlobal#getWindowManagerService",
|
||||||
|
|||||||
Reference in New Issue
Block a user