diff options
Diffstat (limited to 'core/java/android')
38 files changed, 583 insertions, 512 deletions
diff --git a/core/java/android/animation/PropertyValuesHolder.java b/core/java/android/animation/PropertyValuesHolder.java index 43014ad..21f6eda 100644 --- a/core/java/android/animation/PropertyValuesHolder.java +++ b/core/java/android/animation/PropertyValuesHolder.java @@ -743,9 +743,9 @@ public class PropertyValuesHolder implements Cloneable { static class IntPropertyValuesHolder extends PropertyValuesHolder { // Cache JNI functions to avoid looking them up twice - private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = - new HashMap<Class, HashMap<String, Integer>>(); - int mJniSetter; + private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap = + new HashMap<Class, HashMap<String, Long>>(); + long mJniSetter; private IntProperty mIntProperty; IntKeyframeSet mIntKeyframeSet; @@ -845,11 +845,11 @@ public class PropertyValuesHolder implements Cloneable { // Check new static hashmap<propName, int> for setter method try { mPropertyMapLock.writeLock().lock(); - HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass); + HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass); if (propertyMap != null) { - Integer mJniSetterInteger = propertyMap.get(mPropertyName); - if (mJniSetterInteger != null) { - mJniSetter = mJniSetterInteger; + Long jniSetter = propertyMap.get(mPropertyName); + if (jniSetter != null) { + mJniSetter = jniSetter; } } if (mJniSetter == 0) { @@ -857,7 +857,7 @@ public class PropertyValuesHolder implements Cloneable { mJniSetter = nGetIntMethod(targetClass, methodName); if (mJniSetter != 0) { if (propertyMap == null) { - propertyMap = new HashMap<String, Integer>(); + propertyMap = new HashMap<String, Long>(); sJNISetterPropertyMap.put(targetClass, propertyMap); } propertyMap.put(mPropertyName, mJniSetter); @@ -880,9 +880,9 @@ public class PropertyValuesHolder implements Cloneable { static class FloatPropertyValuesHolder extends PropertyValuesHolder { // Cache JNI functions to avoid looking them up twice - private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = - new HashMap<Class, HashMap<String, Integer>>(); - int mJniSetter; + private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap = + new HashMap<Class, HashMap<String, Long>>(); + long mJniSetter; private FloatProperty mFloatProperty; FloatKeyframeSet mFloatKeyframeSet; @@ -982,11 +982,11 @@ public class PropertyValuesHolder implements Cloneable { // Check new static hashmap<propName, int> for setter method try { mPropertyMapLock.writeLock().lock(); - HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass); + HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass); if (propertyMap != null) { - Integer mJniSetterInteger = propertyMap.get(mPropertyName); - if (mJniSetterInteger != null) { - mJniSetter = mJniSetterInteger; + Long jniSetter = propertyMap.get(mPropertyName); + if (jniSetter != null) { + mJniSetter = jniSetter; } } if (mJniSetter == 0) { @@ -994,7 +994,7 @@ public class PropertyValuesHolder implements Cloneable { mJniSetter = nGetFloatMethod(targetClass, methodName); if (mJniSetter != 0) { if (propertyMap == null) { - propertyMap = new HashMap<String, Integer>(); + propertyMap = new HashMap<String, Long>(); sJNISetterPropertyMap.put(targetClass, propertyMap); } propertyMap.put(mPropertyName, mJniSetter); @@ -1015,8 +1015,8 @@ public class PropertyValuesHolder implements Cloneable { } - native static private int nGetIntMethod(Class targetClass, String methodName); - native static private int nGetFloatMethod(Class targetClass, String methodName); - native static private void nCallIntMethod(Object target, int methodID, int arg); - native static private void nCallFloatMethod(Object target, int methodID, float arg); -}
\ No newline at end of file + native static private long nGetIntMethod(Class targetClass, String methodName); + native static private long nGetFloatMethod(Class targetClass, String methodName); + native static private void nCallIntMethod(Object target, long methodID, int arg); + native static private void nCallFloatMethod(Object target, long methodID, float arg); +} diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index d6db8c2..10ef535 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -816,7 +816,7 @@ public class Activity extends ContextThemeWrapper } /** - * Return the LoaderManager for this fragment, creating it if needed. + * Return the LoaderManager for this activity, creating it if needed. */ public LoaderManager getLoaderManager() { if (mLoaderManager != null) { diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 97baf9a..d3080e5 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1541,11 +1541,11 @@ public final class ActivityThread { /** * Creates the top level resources for the given package. */ - Resources getTopLevelResources(String resDir, + Resources getTopLevelResources(String resDir, String[] overlayDirs, int displayId, Configuration overrideConfiguration, LoadedApk pkgInfo) { - return mResourcesManager.getTopLevelResources(resDir, displayId, overrideConfiguration, - pkgInfo.getCompatibilityInfo(), null); + return mResourcesManager.getTopLevelResources(resDir, overlayDirs, displayId, + overrideConfiguration, pkgInfo.getCompatibilityInfo(), null); } final Handler getHandler() { diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index b505d4f..a280448 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -774,7 +774,7 @@ final class ApplicationPackageManager extends PackageManager { } Resources r = mContext.mMainThread.getTopLevelResources( app.uid == Process.myUid() ? app.sourceDir : app.publicSourceDir, - Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo); + app.resourceDirs, Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo); if (r != null) { return r; } diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 190ddb4..8d127c6 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -1911,8 +1911,8 @@ class ContextImpl extends Context { ContextImpl c = new ContextImpl(); c.init(mPackageInfo, null, mMainThread); c.mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(), - getDisplayId(), overrideConfiguration, mResources.getCompatibilityInfo(), - mActivityToken); + mPackageInfo.getOverlayDirs(), getDisplayId(), overrideConfiguration, + mResources.getCompatibilityInfo(), mActivityToken); return c; } @@ -1929,7 +1929,7 @@ class ContextImpl extends Context { context.mDisplay = display; DisplayAdjustments daj = getDisplayAdjustments(displayId); context.mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(), - displayId, null, daj.getCompatibilityInfo(), null); + mPackageInfo.getOverlayDirs(), displayId, null, daj.getCompatibilityInfo(), null); return context; } @@ -2041,7 +2041,8 @@ class ContextImpl extends Context { mDisplayAdjustments.setCompatibilityInfo(compatInfo); mDisplayAdjustments.setActivityToken(activityToken); mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(), - Display.DEFAULT_DISPLAY, null, compatInfo, activityToken); + mPackageInfo.getOverlayDirs(), Display.DEFAULT_DISPLAY, null, compatInfo, + activityToken); } else { mDisplayAdjustments.setCompatibilityInfo(packageInfo.getCompatibilityInfo()); mDisplayAdjustments.setActivityToken(activityToken); diff --git a/core/java/android/app/IAlarmManager.aidl b/core/java/android/app/IAlarmManager.aidl index 8476609..ef9f26e 100644 --- a/core/java/android/app/IAlarmManager.aidl +++ b/core/java/android/app/IAlarmManager.aidl @@ -28,7 +28,7 @@ interface IAlarmManager { /** windowLength == 0 means exact; windowLength < 0 means the let the OS decide */ void set(int type, long triggerAtTime, long windowLength, long interval, in PendingIntent operation, in WorkSource workSource); - void setTime(long millis); + boolean setTime(long millis); void setTimeZone(String zone); void remove(in PendingIntent operation); } diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index 4239a5d..0115d1b 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -76,6 +76,7 @@ public final class LoadedApk { final String mPackageName; private final String mAppDir; private final String mResDir; + private final String[] mOverlayDirs; private final String[] mSharedLibraries; private final String mDataDir; private final String mLibDir; @@ -120,6 +121,7 @@ public final class LoadedApk { final int myUid = Process.myUid(); mResDir = aInfo.uid == myUid ? aInfo.sourceDir : aInfo.publicSourceDir; + mOverlayDirs = aInfo.resourceDirs; if (!UserHandle.isSameUser(aInfo.uid, myUid) && !Process.isIsolated()) { aInfo.dataDir = PackageManager.getDataDirForUser(UserHandle.getUserId(myUid), mPackageName); @@ -159,6 +161,7 @@ public final class LoadedApk { mPackageName = name; mAppDir = null; mResDir = null; + mOverlayDirs = null; mSharedLibraries = null; mDataDir = null; mDataDirFile = null; @@ -471,6 +474,10 @@ public final class LoadedApk { return mResDir; } + public String[] getOverlayDirs() { + return mOverlayDirs; + } + public String getDataDir() { return mDataDir; } @@ -485,7 +492,7 @@ public final class LoadedApk { public Resources getResources(ActivityThread mainThread) { if (mResources == null) { - mResources = mainThread.getTopLevelResources(mResDir, + mResources = mainThread.getTopLevelResources(mResDir, mOverlayDirs, Display.DEFAULT_DISPLAY, null, this); } return mResources; diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java index f55dba4..728f372 100644 --- a/core/java/android/app/ResourcesManager.java +++ b/core/java/android/app/ResourcesManager.java @@ -147,7 +147,7 @@ public class ResourcesManager { * @param compatInfo the compability info. Must not be null. * @param token the application token for determining stack bounds. */ - public Resources getTopLevelResources(String resDir, int displayId, + public Resources getTopLevelResources(String resDir, String[] overlayDirs, int displayId, Configuration overrideConfiguration, CompatibilityInfo compatInfo, IBinder token) { final float scale = compatInfo.applicationScale; ResourcesKey key = new ResourcesKey(resDir, displayId, overrideConfiguration, scale, @@ -180,6 +180,12 @@ public class ResourcesManager { return null; } + if (overlayDirs != null) { + for (String idmapPath : overlayDirs) { + assets.addOverlayPath(idmapPath); + } + } + //Slog.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics); DisplayMetrics dm = getDisplayMetricsLocked(displayId); Configuration config; diff --git a/core/java/android/content/Loader.java b/core/java/android/content/Loader.java index 911e49c..a045b3a 100644 --- a/core/java/android/content/Loader.java +++ b/core/java/android/content/Loader.java @@ -24,7 +24,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; /** - * An abstract class that performs asynchronous loading of data. While Loaders are active + * A class that performs asynchronous loading of data. While Loaders are active * they should monitor the source of their data and deliver new results when the contents * change. See {@link android.app.LoaderManager} for more detail. * diff --git a/core/java/android/content/pm/PackageInfo.java b/core/java/android/content/pm/PackageInfo.java index af1a6d5..785f2b4 100644 --- a/core/java/android/content/pm/PackageInfo.java +++ b/core/java/android/content/pm/PackageInfo.java @@ -227,6 +227,14 @@ public class PackageInfo implements Parcelable { /** @hide */ public String requiredAccountType; + /** + * What package, if any, this package will overlay. + * + * Package name of target package, or null. + * @hide + */ + public String overlayTarget; + public PackageInfo() { } @@ -270,6 +278,7 @@ public class PackageInfo implements Parcelable { dest.writeInt(requiredForAllUsers ? 1 : 0); dest.writeString(restrictedAccountType); dest.writeString(requiredAccountType); + dest.writeString(overlayTarget); } public static final Parcelable.Creator<PackageInfo> CREATOR @@ -311,5 +320,6 @@ public class PackageInfo implements Parcelable { requiredForAllUsers = source.readInt() != 0; restrictedAccountType = source.readString(); requiredAccountType = source.readString(); + overlayTarget = source.readString(); } } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 4607902..52564eb 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -307,6 +307,7 @@ public class PackageParser { } pi.restrictedAccountType = p.mRestrictedAccountType; pi.requiredAccountType = p.mRequiredAccountType; + pi.overlayTarget = p.mOverlayTarget; pi.firstInstallTime = firstInstallTime; pi.lastUpdateTime = lastUpdateTime; if ((flags&PackageManager.GET_GIDS) != 0) { @@ -490,6 +491,11 @@ public class PackageParser { public Package parsePackage(File sourceFile, String destCodePath, DisplayMetrics metrics, int flags) { + return parsePackage(sourceFile, destCodePath, metrics, flags, false); + } + + public Package parsePackage(File sourceFile, String destCodePath, + DisplayMetrics metrics, int flags, boolean trustedOverlay) { mParseError = PackageManager.INSTALL_SUCCEEDED; mArchiveSourcePath = sourceFile.getPath(); @@ -542,7 +548,7 @@ public class PackageParser { Exception errorException = null; try { // XXXX todo: need to figure out correct configuration. - pkg = parsePackage(res, parser, flags, errorText); + pkg = parsePackage(res, parser, flags, trustedOverlay, errorText); } catch (Exception e) { errorException = e; mParseError = PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION; @@ -951,8 +957,8 @@ public class PackageParser { } private Package parsePackage( - Resources res, XmlResourceParser parser, int flags, String[] outError) - throws XmlPullParserException, IOException { + Resources res, XmlResourceParser parser, int flags, boolean trustedOverlay, + String[] outError) throws XmlPullParserException, IOException { AttributeSet attrs = parser; mParseInstrumentationArgs = null; @@ -1051,6 +1057,31 @@ public class PackageParser { if (!parseApplication(pkg, res, parser, attrs, flags, outError)) { return null; } + } else if (tagName.equals("overlay")) { + pkg.mTrustedOverlay = trustedOverlay; + + sa = res.obtainAttributes(attrs, + com.android.internal.R.styleable.AndroidManifestResourceOverlay); + pkg.mOverlayTarget = sa.getString( + com.android.internal.R.styleable.AndroidManifestResourceOverlay_targetPackage); + pkg.mOverlayPriority = sa.getInt( + com.android.internal.R.styleable.AndroidManifestResourceOverlay_priority, + -1); + sa.recycle(); + + if (pkg.mOverlayTarget == null) { + outError[0] = "<overlay> does not specify a target package"; + mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; + return null; + } + if (pkg.mOverlayPriority < 0 || pkg.mOverlayPriority > 9999) { + outError[0] = "<overlay> priority must be between 0 and 9999"; + mParseError = + PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; + return null; + } + XmlUtils.skipCurrentTag(parser); + } else if (tagName.equals("keys")) { if (!parseKeys(pkg, res, parser, attrs, outError)) { return null; @@ -3546,6 +3577,10 @@ public class PackageParser { */ public ManifestDigest manifestDigest; + public String mOverlayTarget; + public int mOverlayPriority; + public boolean mTrustedOverlay; + /** * Data used to feed the KeySetManager */ diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 93ce633..9ce17e4 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -69,13 +69,13 @@ public final class AssetManager { private final long[] mOffsets = new long[2]; // For communication with native code. - private int mObject; + private long mObject; private StringBlock mStringBlocks[] = null; private int mNumRefs = 1; private boolean mOpen = true; - private HashMap<Integer, RuntimeException> mRefStacks; + private HashMap<Long, RuntimeException> mRefStacks; /** * Create a new AssetManager containing only the basic system assets. @@ -90,7 +90,7 @@ public final class AssetManager { mNumRefs = 0; incRefsLocked(this.hashCode()); } - init(); + init(false); if (localLOGV) Log.v(TAG, "New asset manager: " + this); ensureSystemAssets(); } @@ -113,7 +113,7 @@ public final class AssetManager { incRefsLocked(this.hashCode()); } } - init(); + init(true); if (localLOGV) Log.v(TAG, "New asset manager: " + this); } @@ -224,7 +224,7 @@ public final class AssetManager { return retArray; } - /*package*/ final boolean getThemeValue(int theme, int ident, + /*package*/ final boolean getThemeValue(long theme, int ident, TypedValue outValue, boolean resolveRefs) { int block = loadThemeAttributeValue(theme, ident, outValue, resolveRefs); if (block >= 0) { @@ -312,7 +312,7 @@ public final class AssetManager { if (!mOpen) { throw new RuntimeException("Assetmanager has been closed"); } - int asset = openAsset(fileName, accessMode); + long asset = openAsset(fileName, accessMode); if (asset != 0) { AssetInputStream res = new AssetInputStream(asset); incRefsLocked(res.hashCode()); @@ -404,7 +404,7 @@ public final class AssetManager { if (!mOpen) { throw new RuntimeException("Assetmanager has been closed"); } - int asset = openNonAssetNative(cookie, fileName, accessMode); + long asset = openNonAssetNative(cookie, fileName, accessMode); if (asset != 0) { AssetInputStream res = new AssetInputStream(asset); incRefsLocked(res.hashCode()); @@ -484,7 +484,7 @@ public final class AssetManager { if (!mOpen) { throw new RuntimeException("Assetmanager has been closed"); } - int xmlBlock = openXmlAssetNative(cookie, fileName); + long xmlBlock = openXmlAssetNative(cookie, fileName); if (xmlBlock != 0) { XmlBlock res = new XmlBlock(this, xmlBlock); incRefsLocked(res.hashCode()); @@ -500,18 +500,18 @@ public final class AssetManager { } } - /*package*/ final int createTheme() { + /*package*/ final long createTheme() { synchronized (this) { if (!mOpen) { throw new RuntimeException("Assetmanager has been closed"); } - int res = newTheme(); + long res = newTheme(); incRefsLocked(res); return res; } } - /*package*/ final void releaseTheme(int theme) { + /*package*/ final void releaseTheme(long theme) { synchronized (this) { deleteTheme(theme); decRefsLocked(theme); @@ -537,7 +537,7 @@ public final class AssetManager { public final class AssetInputStream extends InputStream { public final int getAssetInt() { - return mAsset; + throw new UnsupportedOperationException(); } /** * @hide @@ -545,7 +545,7 @@ public final class AssetManager { public final long getNativeAsset() { return mAsset; } - private AssetInputStream(int asset) + private AssetInputStream(long asset) { mAsset = asset; mLength = getAssetLength(asset); @@ -597,7 +597,7 @@ public final class AssetManager { close(); } - private int mAsset; + private long mAsset; private long mLength; private long mMarkPos; } @@ -615,6 +615,16 @@ public final class AssetManager { private native final int addAssetPathNative(String path); + /** + * Add a set of assets to overlay an already added set of assets. + * + * This is only intended for application resources. System wide resources + * are handled before any Java code is executed. + * + * {@hide} + */ + public native final int addOverlayPath(String idmapPath); + /** * Add multiple sets of assets to the asset manager at once. See * {@link #addAssetPath(String)} for more information. Returns array of @@ -678,19 +688,19 @@ public final class AssetManager { /*package*/ native final String getResourceTypeName(int resid); /*package*/ native final String getResourceEntryName(int resid); - private native final int openAsset(String fileName, int accessMode); + private native final long openAsset(String fileName, int accessMode); private final native ParcelFileDescriptor openAssetFd(String fileName, long[] outOffsets) throws IOException; - private native final int openNonAssetNative(int cookie, String fileName, + private native final long openNonAssetNative(int cookie, String fileName, int accessMode); private native ParcelFileDescriptor openNonAssetFdNative(int cookie, String fileName, long[] outOffsets) throws IOException; - private native final void destroyAsset(int asset); - private native final int readAssetChar(int asset); - private native final int readAsset(int asset, byte[] b, int off, int len); - private native final long seekAsset(int asset, long offset, int whence); - private native final long getAssetLength(int asset); - private native final long getAssetRemainingLength(int asset); + private native final void destroyAsset(long asset); + private native final int readAssetChar(long asset); + private native final int readAsset(long asset, byte[] b, int off, int len); + private native final long seekAsset(long asset, long offset, int whence); + private native final long getAssetLength(long asset); + private native final long getAssetRemainingLength(long asset); /** Returns true if the resource was found, filling in mRetStringBlock and * mRetData. */ @@ -707,15 +717,15 @@ public final class AssetManager { /*package*/ static final int STYLE_RESOURCE_ID = 3; /*package*/ static final int STYLE_CHANGING_CONFIGURATIONS = 4; /*package*/ static final int STYLE_DENSITY = 5; - /*package*/ native static final boolean applyStyle(int theme, - int defStyleAttr, int defStyleRes, int xmlParser, + /*package*/ native static final boolean applyStyle(long theme, + int defStyleAttr, int defStyleRes, long xmlParser, int[] inAttrs, int[] outValues, int[] outIndices); /*package*/ native final boolean retrieveAttributes( - int xmlParser, int[] inAttrs, int[] outValues, int[] outIndices); + long xmlParser, int[] inAttrs, int[] outValues, int[] outIndices); /*package*/ native final int getArraySize(int resource); /*package*/ native final int retrieveArray(int resource, int[] outValues); private native final int getStringBlockCount(); - private native final int getNativeStringBlock(int block); + private native final long getNativeStringBlock(int block); /** * {@hide} @@ -737,37 +747,37 @@ public final class AssetManager { */ public native static final int getGlobalAssetManagerCount(); - private native final int newTheme(); - private native final void deleteTheme(int theme); - /*package*/ native static final void applyThemeStyle(int theme, int styleRes, boolean force); - /*package*/ native static final void copyTheme(int dest, int source); - /*package*/ native static final int loadThemeAttributeValue(int theme, int ident, + private native final long newTheme(); + private native final void deleteTheme(long theme); + /*package*/ native static final void applyThemeStyle(long theme, int styleRes, boolean force); + /*package*/ native static final void copyTheme(long dest, long source); + /*package*/ native static final int loadThemeAttributeValue(long theme, int ident, TypedValue outValue, boolean resolve); - /*package*/ native static final void dumpTheme(int theme, int priority, String tag, String prefix); + /*package*/ native static final void dumpTheme(long theme, int priority, String tag, String prefix); - private native final int openXmlAssetNative(int cookie, String fileName); + private native final long openXmlAssetNative(int cookie, String fileName); private native final String[] getArrayStringResource(int arrayRes); private native final int[] getArrayStringInfo(int arrayRes); /*package*/ native final int[] getArrayIntResource(int arrayRes); - private native final void init(); + private native final void init(boolean isSystem); private native final void destroy(); - private final void incRefsLocked(int id) { + private final void incRefsLocked(long id) { if (DEBUG_REFS) { if (mRefStacks == null) { - mRefStacks = new HashMap<Integer, RuntimeException>(); - RuntimeException ex = new RuntimeException(); - ex.fillInStackTrace(); - mRefStacks.put(this.hashCode(), ex); + mRefStacks = new HashMap<Long, RuntimeException>(); } + RuntimeException ex = new RuntimeException(); + ex.fillInStackTrace(); + mRefStacks.put(id, ex); } mNumRefs++; } - private final void decRefsLocked(int id) { + private final void decRefsLocked(long id) { if (DEBUG_REFS && mRefStacks != null) { mRefStacks.remove(id); } diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index cd5b5d2..3d9daca 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -1460,7 +1460,7 @@ public class Resources { } private final AssetManager mAssets; - private final int mTheme; + private final long mTheme; } /** @@ -1569,10 +1569,7 @@ public class Resources { String locale = null; if (mConfiguration.locale != null) { - locale = mConfiguration.locale.getLanguage(); - if (mConfiguration.locale.getCountry() != null) { - locale += "-" + mConfiguration.locale.getCountry(); - } + locale = mConfiguration.locale.toLanguageTag(); } int width, height; if (mMetrics.widthPixels >= mMetrics.heightPixels) { diff --git a/core/java/android/content/res/StringBlock.java b/core/java/android/content/res/StringBlock.java index 78180b1..77b8a33 100644 --- a/core/java/android/content/res/StringBlock.java +++ b/core/java/android/content/res/StringBlock.java @@ -36,7 +36,7 @@ final class StringBlock { private static final String TAG = "AssetManager"; private static final boolean localLOGV = false; - private final int mNative; + private final long mNative; private final boolean mUseSparse; private final boolean mOwnsNative; private CharSequence[] mStrings; @@ -474,7 +474,7 @@ final class StringBlock { * are doing! The given native object must exist for the entire lifetime * of this newly creating StringBlock. */ - StringBlock(int obj, boolean useSparse) { + StringBlock(long obj, boolean useSparse) { mNative = obj; mUseSparse = useSparse; mOwnsNative = false; @@ -482,11 +482,11 @@ final class StringBlock { + ": " + nativeGetSize(mNative)); } - private static native int nativeCreate(byte[] data, + private static native long nativeCreate(byte[] data, int offset, int size); - private static native int nativeGetSize(int obj); - private static native String nativeGetString(int obj, int idx); - private static native int[] nativeGetStyle(int obj, int idx); - private static native void nativeDestroy(int obj); + private static native int nativeGetSize(long obj); + private static native String nativeGetString(long obj, int idx); + private static native int[] nativeGetStyle(long obj, int idx); + private static native void nativeDestroy(long obj); } diff --git a/core/java/android/content/res/XmlBlock.java b/core/java/android/content/res/XmlBlock.java index bea6529..3ad357f 100644 --- a/core/java/android/content/res/XmlBlock.java +++ b/core/java/android/content/res/XmlBlock.java @@ -75,7 +75,7 @@ final class XmlBlock { } /*package*/ final class Parser implements XmlResourceParser { - Parser(int parseState, XmlBlock block) { + Parser(long parseState, XmlBlock block) { mParseState = parseState; mBlock = block; block.mOpenCount++; @@ -458,7 +458,7 @@ final class XmlBlock { return mStrings.get(id); } - /*package*/ int mParseState; + /*package*/ long mParseState; private final XmlBlock mBlock; private boolean mStarted = false; private boolean mDecNextDepth = false; @@ -476,41 +476,41 @@ final class XmlBlock { * are doing! The given native object must exist for the entire lifetime * of this newly creating XmlBlock. */ - XmlBlock(AssetManager assets, int xmlBlock) { + XmlBlock(AssetManager assets, long xmlBlock) { mAssets = assets; mNative = xmlBlock; mStrings = new StringBlock(nativeGetStringBlock(xmlBlock), false); } private final AssetManager mAssets; - private final int mNative; + private final long mNative; /*package*/ final StringBlock mStrings; private boolean mOpen = true; private int mOpenCount = 1; - private static final native int nativeCreate(byte[] data, + private static final native long nativeCreate(byte[] data, int offset, int size); - private static final native int nativeGetStringBlock(int obj); + private static final native long nativeGetStringBlock(long obj); - private static final native int nativeCreateParseState(int obj); - /*package*/ static final native int nativeNext(int state); - private static final native int nativeGetNamespace(int state); - /*package*/ static final native int nativeGetName(int state); - private static final native int nativeGetText(int state); - private static final native int nativeGetLineNumber(int state); - private static final native int nativeGetAttributeCount(int state); - private static final native int nativeGetAttributeNamespace(int state, int idx); - private static final native int nativeGetAttributeName(int state, int idx); - private static final native int nativeGetAttributeResource(int state, int idx); - private static final native int nativeGetAttributeDataType(int state, int idx); - private static final native int nativeGetAttributeData(int state, int idx); - private static final native int nativeGetAttributeStringValue(int state, int idx); - private static final native int nativeGetIdAttribute(int state); - private static final native int nativeGetClassAttribute(int state); - private static final native int nativeGetStyleAttribute(int state); - private static final native int nativeGetAttributeIndex(int state, String namespace, String name); - private static final native void nativeDestroyParseState(int state); + private static final native long nativeCreateParseState(long obj); + /*package*/ static final native int nativeNext(long state); + private static final native int nativeGetNamespace(long state); + /*package*/ static final native int nativeGetName(long state); + private static final native int nativeGetText(long state); + private static final native int nativeGetLineNumber(long state); + private static final native int nativeGetAttributeCount(long state); + private static final native int nativeGetAttributeNamespace(long state, int idx); + private static final native int nativeGetAttributeName(long state, int idx); + private static final native int nativeGetAttributeResource(long state, int idx); + private static final native int nativeGetAttributeDataType(long state, int idx); + private static final native int nativeGetAttributeData(long state, int idx); + private static final native int nativeGetAttributeStringValue(long state, int idx); + private static final native int nativeGetIdAttribute(long state); + private static final native int nativeGetClassAttribute(long state); + private static final native int nativeGetStyleAttribute(long state); + private static final native int nativeGetAttributeIndex(long state, String namespace, String name); + private static final native void nativeDestroyParseState(long state); - private static final native void nativeDestroy(int obj); + private static final native void nativeDestroy(long obj); } diff --git a/core/java/android/debug/JNITest.java b/core/java/android/debug/JNITest.java deleted file mode 100644 index 2ce374a..0000000 --- a/core/java/android/debug/JNITest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.debug; - -/** - * Simple JNI verification test. - */ -public class JNITest { - - public JNITest() { - } - - public int test(int intArg, double doubleArg, String stringArg) { - int[] intArray = { 42, 53, 65, 127 }; - - return part1(intArg, doubleArg, stringArg, intArray); - } - - private native int part1(int intArg, double doubleArg, String stringArg, - int[] arrayArg); - - private int part2(double doubleArg, int fromArray, String stringArg) { - int result; - - System.out.println(stringArg + " : " + (float) doubleArg + " : " + - fromArray); - result = part3(stringArg); - - return result + 6; - } - - private static native int part3(String stringArg); -} - diff --git a/core/java/android/emoji/EmojiFactory.java b/core/java/android/emoji/EmojiFactory.java index 8fd8695..aba990d 100644 --- a/core/java/android/emoji/EmojiFactory.java +++ b/core/java/android/emoji/EmojiFactory.java @@ -54,7 +54,7 @@ public final class EmojiFactory { } // A pointer to native EmojiFactory object. - private int mNativeEmojiFactory; + private long mNativeEmojiFactory; private String mName; // Cache. private Map<Integer, WeakReference<Bitmap>> mCache; @@ -68,7 +68,7 @@ public final class EmojiFactory { * * This can be called from JNI code. */ - private EmojiFactory(int nativeEmojiFactory, String name) { + private EmojiFactory(long nativeEmojiFactory, String name) { mNativeEmojiFactory = nativeEmojiFactory; mName = name; mCache = new CustomLinkedHashMap<Integer, WeakReference<Bitmap>>(); @@ -272,18 +272,18 @@ public final class EmojiFactory { // native methods - private native void nativeDestructor(int factory); - private native Bitmap nativeGetBitmapFromAndroidPua(int nativeEmojiFactory, int AndroidPua); - private native int nativeGetAndroidPuaFromVendorSpecificSjis(int nativeEmojiFactory, + private native void nativeDestructor(long nativeEmojiFactory); + private native Bitmap nativeGetBitmapFromAndroidPua(long nativeEmojiFactory, int AndroidPua); + private native int nativeGetAndroidPuaFromVendorSpecificSjis(long nativeEmojiFactory, char sjis); - private native int nativeGetVendorSpecificSjisFromAndroidPua(int nativeEmojiFactory, + private native int nativeGetVendorSpecificSjisFromAndroidPua(long nativeEmojiFactory, int pua); - private native int nativeGetAndroidPuaFromVendorSpecificPua(int nativeEmojiFactory, + private native int nativeGetAndroidPuaFromVendorSpecificPua(long nativeEmojiFactory, int vsp); - private native int nativeGetVendorSpecificPuaFromAndroidPua(int nativeEmojiFactory, + private native int nativeGetVendorSpecificPuaFromAndroidPua(long nativeEmojiFactory, int pua); - private native int nativeGetMaximumVendorSpecificPua(int nativeEmojiFactory); - private native int nativeGetMinimumVendorSpecificPua(int nativeEmojiFactory); - private native int nativeGetMaximumAndroidPua(int nativeEmojiFactory); - private native int nativeGetMinimumAndroidPua(int nativeEmojiFactory); + private native int nativeGetMaximumVendorSpecificPua(long nativeEmojiFactory); + private native int nativeGetMinimumVendorSpecificPua(long nativeEmojiFactory); + private native int nativeGetMaximumAndroidPua(long nativeEmojiFactory); + private native int nativeGetMinimumAndroidPua(long nativeEmojiFactory); } diff --git a/core/java/android/net/LocalSocketImpl.java b/core/java/android/net/LocalSocketImpl.java index b2ee50a..119e533 100644 --- a/core/java/android/net/LocalSocketImpl.java +++ b/core/java/android/net/LocalSocketImpl.java @@ -326,6 +326,7 @@ class LocalSocketImpl } s.fd = accept(fd, s); + s.mFdCreatedInternally = true; } /** @@ -536,4 +537,3 @@ class LocalSocketImpl close(); } } - diff --git a/core/java/android/net/nsd/NsdManager.java b/core/java/android/net/nsd/NsdManager.java index 9c3e405..7b2c623 100644 --- a/core/java/android/net/nsd/NsdManager.java +++ b/core/java/android/net/nsd/NsdManager.java @@ -301,27 +301,36 @@ public final class NsdManager { @Override public void handleMessage(Message message) { - Object listener = getListener(message.arg2); - boolean listenerRemove = true; switch (message.what) { case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED: mAsyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION); - break; + return; case AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED: mConnected.countDown(); - break; + return; case AsyncChannel.CMD_CHANNEL_DISCONNECTED: Log.e(TAG, "Channel lost"); + return; + default: break; + } + Object listener = getListener(message.arg2); + if (listener == null) { + Log.d(TAG, "Stale key " + message.arg2); + return; + } + boolean listenerRemove = true; + NsdServiceInfo ns = getNsdService(message.arg2); + switch (message.what) { case DISCOVER_SERVICES_STARTED: - String s = ((NsdServiceInfo) message.obj).getServiceType(); + String s = getNsdServiceInfoType((NsdServiceInfo) message.obj); ((DiscoveryListener) listener).onDiscoveryStarted(s); // Keep listener until stop discovery listenerRemove = false; break; case DISCOVER_SERVICES_FAILED: - ((DiscoveryListener) listener).onStartDiscoveryFailed( - getNsdService(message.arg2).getServiceType(), message.arg1); + ((DiscoveryListener) listener).onStartDiscoveryFailed(getNsdServiceInfoType(ns), + message.arg1); break; case SERVICE_FOUND: ((DiscoveryListener) listener).onServiceFound((NsdServiceInfo) message.obj); @@ -334,16 +343,14 @@ public final class NsdManager { listenerRemove = false; break; case STOP_DISCOVERY_FAILED: - ((DiscoveryListener) listener).onStopDiscoveryFailed( - getNsdService(message.arg2).getServiceType(), message.arg1); + ((DiscoveryListener) listener).onStopDiscoveryFailed(getNsdServiceInfoType(ns), + message.arg1); break; case STOP_DISCOVERY_SUCCEEDED: - ((DiscoveryListener) listener).onDiscoveryStopped( - getNsdService(message.arg2).getServiceType()); + ((DiscoveryListener) listener).onDiscoveryStopped(getNsdServiceInfoType(ns)); break; case REGISTER_SERVICE_FAILED: - ((RegistrationListener) listener).onRegistrationFailed( - getNsdService(message.arg2), message.arg1); + ((RegistrationListener) listener).onRegistrationFailed(ns, message.arg1); break; case REGISTER_SERVICE_SUCCEEDED: ((RegistrationListener) listener).onServiceRegistered( @@ -352,16 +359,13 @@ public final class NsdManager { listenerRemove = false; break; case UNREGISTER_SERVICE_FAILED: - ((RegistrationListener) listener).onUnregistrationFailed( - getNsdService(message.arg2), message.arg1); + ((RegistrationListener) listener).onUnregistrationFailed(ns, message.arg1); break; case UNREGISTER_SERVICE_SUCCEEDED: - ((RegistrationListener) listener).onServiceUnregistered( - getNsdService(message.arg2)); + ((RegistrationListener) listener).onServiceUnregistered(ns); break; case RESOLVE_SERVICE_FAILED: - ((ResolveListener) listener).onResolveFailed( - getNsdService(message.arg2), message.arg1); + ((ResolveListener) listener).onResolveFailed(ns, message.arg1); break; case RESOLVE_SERVICE_SUCCEEDED: ((ResolveListener) listener).onServiceResolved((NsdServiceInfo) message.obj); @@ -421,6 +425,11 @@ public final class NsdManager { } + private String getNsdServiceInfoType(NsdServiceInfo s) { + if (s == null) return "?"; + return s.getServiceType(); + } + /** * Initialize AsyncChannel */ diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index f4a8391..ba71605 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -56,7 +56,7 @@ public class Binder implements IBinder { private static String sDumpDisabled = null; /* mObject is used by native code, do not remove or rename */ - private int mObject; + private long mObject; private IInterface mOwner; private String mDescriptor; @@ -390,7 +390,7 @@ public class Binder implements IBinder { private native final void destroy(); // Entry point from android_util_Binder.cpp's onTransact - private boolean execTransact(int code, int dataObj, int replyObj, + private boolean execTransact(int code, long dataObj, long replyObj, int flags) { Parcel data = Parcel.obtain(dataObj); Parcel reply = Parcel.obtain(replyObj); @@ -499,6 +499,6 @@ final class BinderProxy implements IBinder { } final private WeakReference mSelf; - private int mObject; - private int mOrgue; + private long mObject; + private long mOrgue; } diff --git a/core/java/android/os/CountDownTimer.java b/core/java/android/os/CountDownTimer.java index 15e6405..58acbcf 100644 --- a/core/java/android/os/CountDownTimer.java +++ b/core/java/android/os/CountDownTimer.java @@ -16,8 +16,6 @@ package android.os; -import android.util.Log; - /** * Schedule a countdown until a time in the future, with * regular notifications on intervals along the way. @@ -56,6 +54,11 @@ public abstract class CountDownTimer { private final long mCountdownInterval; private long mStopTimeInFuture; + + /** + * boolean representing if the timer was cancelled + */ + private boolean mCancelled = false; /** * @param millisInFuture The number of millis in the future from the call @@ -72,7 +75,8 @@ public abstract class CountDownTimer { /** * Cancel the countdown. */ - public final void cancel() { + public synchronized final void cancel() { + mCancelled = true; mHandler.removeMessages(MSG); } @@ -80,6 +84,7 @@ public abstract class CountDownTimer { * Start the countdown. */ public synchronized final CountDownTimer start() { + mCancelled = false; if (mMillisInFuture <= 0) { onFinish(); return this; @@ -112,6 +117,10 @@ public abstract class CountDownTimer { public void handleMessage(Message msg) { synchronized (CountDownTimer.this) { + if (mCancelled) { + return; + } + final long millisLeft = mStopTimeInFuture - SystemClock.elapsedRealtime(); if (millisLeft <= 0) { diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 94b9617..7425f67 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -182,7 +182,7 @@ public final class Parcel { private static final String TAG = "Parcel"; @SuppressWarnings({"UnusedDeclaration"}) - private int mNativePtr; // used by native code + private long mNativePtr; // used by native code /** * Flag indicating if {@link #mNativePtr} was allocated by this object, @@ -232,47 +232,47 @@ public final class Parcel { private static final int EX_NETWORK_MAIN_THREAD = -6; private static final int EX_HAS_REPLY_HEADER = -128; // special; see below - private static native int nativeDataSize(int nativePtr); - private static native int nativeDataAvail(int nativePtr); - private static native int nativeDataPosition(int nativePtr); - private static native int nativeDataCapacity(int nativePtr); - private static native void nativeSetDataSize(int nativePtr, int size); - private static native void nativeSetDataPosition(int nativePtr, int pos); - private static native void nativeSetDataCapacity(int nativePtr, int size); - - private static native boolean nativePushAllowFds(int nativePtr, boolean allowFds); - private static native void nativeRestoreAllowFds(int nativePtr, boolean lastValue); - - private static native void nativeWriteByteArray(int nativePtr, byte[] b, int offset, int len); - private static native void nativeWriteInt(int nativePtr, int val); - private static native void nativeWriteLong(int nativePtr, long val); - private static native void nativeWriteFloat(int nativePtr, float val); - private static native void nativeWriteDouble(int nativePtr, double val); - private static native void nativeWriteString(int nativePtr, String val); - private static native void nativeWriteStrongBinder(int nativePtr, IBinder val); - private static native void nativeWriteFileDescriptor(int nativePtr, FileDescriptor val); - - private static native byte[] nativeCreateByteArray(int nativePtr); - private static native int nativeReadInt(int nativePtr); - private static native long nativeReadLong(int nativePtr); - private static native float nativeReadFloat(int nativePtr); - private static native double nativeReadDouble(int nativePtr); - private static native String nativeReadString(int nativePtr); - private static native IBinder nativeReadStrongBinder(int nativePtr); - private static native FileDescriptor nativeReadFileDescriptor(int nativePtr); - - private static native int nativeCreate(); - private static native void nativeFreeBuffer(int nativePtr); - private static native void nativeDestroy(int nativePtr); - - private static native byte[] nativeMarshall(int nativePtr); + private static native int nativeDataSize(long nativePtr); + private static native int nativeDataAvail(long nativePtr); + private static native int nativeDataPosition(long nativePtr); + private static native int nativeDataCapacity(long nativePtr); + private static native void nativeSetDataSize(long nativePtr, int size); + private static native void nativeSetDataPosition(long nativePtr, int pos); + private static native void nativeSetDataCapacity(long nativePtr, int size); + + private static native boolean nativePushAllowFds(long nativePtr, boolean allowFds); + private static native void nativeRestoreAllowFds(long nativePtr, boolean lastValue); + + private static native void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len); + private static native void nativeWriteInt(long nativePtr, int val); + private static native void nativeWriteLong(long nativePtr, long val); + private static native void nativeWriteFloat(long nativePtr, float val); + private static native void nativeWriteDouble(long nativePtr, double val); + private static native void nativeWriteString(long nativePtr, String val); + private static native void nativeWriteStrongBinder(long nativePtr, IBinder val); + private static native void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val); + + private static native byte[] nativeCreateByteArray(long nativePtr); + private static native int nativeReadInt(long nativePtr); + private static native long nativeReadLong(long nativePtr); + private static native float nativeReadFloat(long nativePtr); + private static native double nativeReadDouble(long nativePtr); + private static native String nativeReadString(long nativePtr); + private static native IBinder nativeReadStrongBinder(long nativePtr); + private static native FileDescriptor nativeReadFileDescriptor(long nativePtr); + + private static native long nativeCreate(); + private static native void nativeFreeBuffer(long nativePtr); + private static native void nativeDestroy(long nativePtr); + + private static native byte[] nativeMarshall(long nativePtr); private static native void nativeUnmarshall( - int nativePtr, byte[] data, int offest, int length); + long nativePtr, byte[] data, int offest, int length); private static native void nativeAppendFrom( - int thisNativePtr, int otherNativePtr, int offset, int length); - private static native boolean nativeHasFileDescriptors(int nativePtr); - private static native void nativeWriteInterfaceToken(int nativePtr, String interfaceName); - private static native void nativeEnforceInterface(int nativePtr, String interfaceName); + long thisNativePtr, long otherNativePtr, int offset, int length); + private static native boolean nativeHasFileDescriptors(long nativePtr); + private static native void nativeWriteInterfaceToken(long nativePtr, String interfaceName); + private static native void nativeEnforceInterface(long nativePtr, String interfaceName); public final static Parcelable.Creator<String> STRING_CREATOR = new Parcelable.Creator<String>() { @@ -1246,9 +1246,6 @@ public final class Parcel { } else if (v instanceof Parcelable[]) { writeInt(VAL_PARCELABLEARRAY); writeParcelableArray((Parcelable[]) v, 0); - } else if (v instanceof Object[]) { - writeInt(VAL_OBJECTARRAY); - writeArray((Object[]) v); } else if (v instanceof int[]) { writeInt(VAL_INTARRAY); writeIntArray((int[]) v); @@ -1258,12 +1255,20 @@ public final class Parcel { } else if (v instanceof Byte) { writeInt(VAL_BYTE); writeInt((Byte) v); - } else if (v instanceof Serializable) { - // Must be last - writeInt(VAL_SERIALIZABLE); - writeSerializable((Serializable) v); } else { - throw new RuntimeException("Parcel: unable to marshal value " + v); + Class<?> clazz = v.getClass(); + if (clazz.isArray() && clazz.getComponentType() == Object.class) { + // Only pure Object[] are written here, Other arrays of non-primitive types are + // handled by serialization as this does not record the component type. + writeInt(VAL_OBJECTARRAY); + writeArray((Object[]) v); + } else if (v instanceof Serializable) { + // Must be last + writeInt(VAL_SERIALIZABLE); + writeSerializable((Serializable) v); + } else { + throw new RuntimeException("Parcel: unable to marshal value " + v); + } } } @@ -1454,10 +1459,11 @@ public final class Parcel { } /** - * Use this function for customized exception handling. - * customized method call this method for all unknown case - * @param code exception code - * @param msg exception message + * Throw an exception with the given message. Not intended for use + * outside the Parcel class. + * + * @param code Used to determine which exception class to throw. + * @param msg The exception message. */ public final void readException(int code, String msg) { switch (code) { @@ -2229,6 +2235,11 @@ public final class Parcel { mCreators = new HashMap<ClassLoader,HashMap<String,Parcelable.Creator>>(); static protected final Parcel obtain(int obj) { + throw new UnsupportedOperationException(); + } + + /** @hide */ + static protected final Parcel obtain(long obj) { final Parcel[] pool = sHolderPool; synchronized (pool) { Parcel p; @@ -2247,7 +2258,7 @@ public final class Parcel { return new Parcel(obj); } - private Parcel(int nativePtr) { + private Parcel(long nativePtr) { if (DEBUG_RECYCLE) { mStack = new RuntimeException(); } @@ -2255,7 +2266,7 @@ public final class Parcel { init(nativePtr); } - private void init(int nativePtr) { + private void init(long nativePtr) { if (nativePtr != 0) { mNativePtr = nativePtr; mOwnsNativeParcelObject = false; diff --git a/core/java/android/os/SystemClock.java b/core/java/android/os/SystemClock.java index 729c64b..672df6d 100644 --- a/core/java/android/os/SystemClock.java +++ b/core/java/android/os/SystemClock.java @@ -16,6 +16,9 @@ package android.os; +import android.app.IAlarmManager; +import android.content.Context; +import android.util.Slog; /** * Core timekeeping facilities. @@ -89,6 +92,8 @@ package android.os; * </ul> */ public final class SystemClock { + private static final String TAG = "SystemClock"; + /** * This class is uninstantiable. */ @@ -134,7 +139,23 @@ public final class SystemClock { * * @return if the clock was successfully set to the specified time. */ - native public static boolean setCurrentTimeMillis(long millis); + public static boolean setCurrentTimeMillis(long millis) { + IBinder b = ServiceManager.getService(Context.ALARM_SERVICE); + IAlarmManager mgr = IAlarmManager.Stub.asInterface(b); + if (mgr == null) { + return false; + } + + try { + return mgr.setTime(millis); + } catch (RemoteException e) { + Slog.e(TAG, "Unable to set RTC", e); + } catch (SecurityException e) { + Slog.e(TAG, "Unable to set RTC", e); + } + + return false; + } /** * Returns milliseconds since boot, not counting time spent in deep sleep. diff --git a/core/java/android/util/JsonReader.java b/core/java/android/util/JsonReader.java index f2a86c9..7d1c6c4 100644 --- a/core/java/android/util/JsonReader.java +++ b/core/java/android/util/JsonReader.java @@ -546,6 +546,9 @@ public final class JsonReader implements Closeable { public void skipValue() throws IOException { skipping = true; try { + if (!hasNext() || peek() == JsonToken.END_DOCUMENT) { + throw new IllegalStateException("No element left to skip"); + } int count = 0; do { JsonToken token = advance(); diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java index beefc21..d533060 100644 --- a/core/java/android/view/GLES20Canvas.java +++ b/core/java/android/view/GLES20Canvas.java @@ -49,7 +49,7 @@ class GLES20Canvas extends HardwareCanvas { private static final int MODIFIER_COLOR_FILTER = 4; private final boolean mOpaque; - private int mRenderer; + private long mRenderer; // The native renderer will be destroyed when this object dies. // DO NOT overwrite this reference once it is set. @@ -92,7 +92,7 @@ class GLES20Canvas extends HardwareCanvas { /** * Creates a canvas to render into an FBO. */ - GLES20Canvas(int layer, boolean translucent) { + GLES20Canvas(long layer, boolean translucent) { mOpaque = !translucent; mRenderer = nCreateLayerRenderer(layer); setupFinalizer(); @@ -122,16 +122,16 @@ class GLES20Canvas extends HardwareCanvas { nResetDisplayListRenderer(mRenderer); } - private static native int nCreateRenderer(); - private static native int nCreateLayerRenderer(int layer); - private static native int nCreateDisplayListRenderer(); - private static native void nResetDisplayListRenderer(int renderer); - private static native void nDestroyRenderer(int renderer); + private static native long nCreateRenderer(); + private static native long nCreateLayerRenderer(long layer); + private static native long nCreateDisplayListRenderer(); + private static native void nResetDisplayListRenderer(long renderer); + private static native void nDestroyRenderer(long renderer); private static final class CanvasFinalizer { - private final int mRenderer; + private final long mRenderer; - public CanvasFinalizer(int renderer) { + public CanvasFinalizer(long renderer) { mRenderer = renderer; } @@ -151,7 +151,7 @@ class GLES20Canvas extends HardwareCanvas { nSetName(mRenderer, name); } - private static native void nSetName(int renderer, String name); + private static native void nSetName(long renderer, String name); /////////////////////////////////////////////////////////////////////////// // Hardware layers @@ -177,26 +177,26 @@ class GLES20Canvas extends HardwareCanvas { nClearLayerUpdates(mRenderer); } - static native int nCreateTextureLayer(boolean opaque, int[] layerInfo); - static native int nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo); - static native boolean nResizeLayer(int layerId, int width, int height, int[] layerInfo); - static native void nSetOpaqueLayer(int layerId, boolean isOpaque); - static native void nSetLayerPaint(int layerId, int nativePaint); - static native void nSetLayerColorFilter(int layerId, int nativeColorFilter); - static native void nUpdateTextureLayer(int layerId, int width, int height, boolean opaque, + static native long nCreateTextureLayer(boolean opaque, int[] layerInfo); + static native long nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo); + static native boolean nResizeLayer(long layerId, int width, int height, int[] layerInfo); + static native void nSetOpaqueLayer(long layerId, boolean isOpaque); + static native void nSetLayerPaint(long layerId, long nativePaint); + static native void nSetLayerColorFilter(long layerId, long nativeColorFilter); + static native void nUpdateTextureLayer(long layerId, int width, int height, boolean opaque, SurfaceTexture surface); - static native void nClearLayerTexture(int layerId); - static native void nSetTextureLayerTransform(int layerId, int matrix); - static native void nDestroyLayer(int layerId); - static native void nDestroyLayerDeferred(int layerId); - static native void nUpdateRenderLayer(int layerId, int renderer, int displayList, + static native void nClearLayerTexture(long layerId); + static native void nSetTextureLayerTransform(long layerId, long matrix); + static native void nDestroyLayer(long layerId); + static native void nDestroyLayerDeferred(long layerId); + static native void nUpdateRenderLayer(long layerId, long renderer, long displayList, int left, int top, int right, int bottom); - static native boolean nCopyLayer(int layerId, int bitmap); + static native boolean nCopyLayer(long layerId, long bitmap); - private static native void nClearLayerUpdates(int renderer); - private static native void nFlushLayerUpdates(int renderer); - private static native void nPushLayerUpdate(int renderer, int layer); - private static native void nCancelLayerUpdate(int renderer, int layer); + private static native void nClearLayerUpdates(long renderer); + private static native void nFlushLayerUpdates(long renderer); + private static native void nPushLayerUpdate(long renderer, long layer); + private static native void nCancelLayerUpdate(long renderer, long layer); /////////////////////////////////////////////////////////////////////////// // Canvas management @@ -233,7 +233,7 @@ class GLES20Canvas extends HardwareCanvas { /** * Returns the native OpenGLRenderer object. */ - int getRenderer() { + long getRenderer() { return mRenderer; } @@ -249,7 +249,7 @@ class GLES20Canvas extends HardwareCanvas { nSetViewport(mRenderer, width, height); } - private static native void nSetViewport(int renderer, int width, int height); + private static native void nSetViewport(long renderer, int width, int height); @Override public int onPreDraw(Rect dirty) { @@ -261,8 +261,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native int nPrepare(int renderer, boolean opaque); - private static native int nPrepareDirty(int renderer, int left, int top, int right, int bottom, + private static native int nPrepare(long renderer, boolean opaque); + private static native int nPrepareDirty(long renderer, int left, int top, int right, int bottom, boolean opaque); @Override @@ -270,7 +270,7 @@ class GLES20Canvas extends HardwareCanvas { nFinish(mRenderer); } - private static native void nFinish(int renderer); + private static native void nFinish(long renderer); /** * Returns the size of the stencil buffer required by the underlying @@ -290,45 +290,45 @@ class GLES20Canvas extends HardwareCanvas { nSetCountOverdrawEnabled(mRenderer, enabled); } - static native void nSetCountOverdrawEnabled(int renderer, boolean enabled); + static native void nSetCountOverdrawEnabled(long renderer, boolean enabled); float getOverdraw() { return nGetOverdraw(mRenderer); } - static native float nGetOverdraw(int renderer); + static native float nGetOverdraw(long renderer); /////////////////////////////////////////////////////////////////////////// // Functor /////////////////////////////////////////////////////////////////////////// @Override - public int callDrawGLFunction(int drawGLFunction) { + public int callDrawGLFunction(long drawGLFunction) { return nCallDrawGLFunction(mRenderer, drawGLFunction); } - private static native int nCallDrawGLFunction(int renderer, int drawGLFunction); + private static native int nCallDrawGLFunction(long renderer, long drawGLFunction); @Override public int invokeFunctors(Rect dirty) { return nInvokeFunctors(mRenderer, dirty); } - private static native int nInvokeFunctors(int renderer, Rect dirty); + private static native int nInvokeFunctors(long renderer, Rect dirty); @Override - public void detachFunctor(int functor) { + public void detachFunctor(long functor) { nDetachFunctor(mRenderer, functor); } - private static native void nDetachFunctor(int renderer, int functor); + private static native void nDetachFunctor(long renderer, long functor); @Override - public void attachFunctor(int functor) { + public void attachFunctor(long functor) { nAttachFunctor(mRenderer, functor); } - private static native void nAttachFunctor(int renderer, int functor); + private static native void nAttachFunctor(long renderer, long functor); /////////////////////////////////////////////////////////////////////////// // Memory @@ -392,28 +392,28 @@ class GLES20Canvas extends HardwareCanvas { // Atlas /////////////////////////////////////////////////////////////////////////// - static void initAtlas(GraphicBuffer buffer, int[] map) { + static void initAtlas(GraphicBuffer buffer, long[] map) { nInitAtlas(buffer, map, map.length); } - private static native void nInitAtlas(GraphicBuffer buffer, int[] map, int count); + private static native void nInitAtlas(GraphicBuffer buffer, long[] map, int count); /////////////////////////////////////////////////////////////////////////// // Display list /////////////////////////////////////////////////////////////////////////// - int getDisplayList(int displayList) { + long getDisplayList(long displayList) { return nGetDisplayList(mRenderer, displayList); } - private static native int nGetDisplayList(int renderer, int displayList); + private static native long nGetDisplayList(long renderer, long displayList); @Override void outputDisplayList(DisplayList displayList) { nOutputDisplayList(mRenderer, ((GLES20DisplayList) displayList).getNativeDisplayList()); } - private static native void nOutputDisplayList(int renderer, int displayList); + private static native void nOutputDisplayList(long renderer, long displayList); @Override public int drawDisplayList(DisplayList displayList, Rect dirty, int flags) { @@ -421,7 +421,7 @@ class GLES20Canvas extends HardwareCanvas { dirty, flags); } - private static native int nDrawDisplayList(int renderer, int displayList, + private static native int nDrawDisplayList(long renderer, long displayList, Rect dirty, int flags); /////////////////////////////////////////////////////////////////////////// @@ -435,7 +435,7 @@ class GLES20Canvas extends HardwareCanvas { nDrawLayer(mRenderer, glLayer.getLayer(), x, y); } - private static native void nDrawLayer(int renderer, int layer, float x, float y); + private static native void nDrawLayer(long renderer, long layer, float x, float y); void interrupt() { nInterrupt(mRenderer); @@ -445,8 +445,8 @@ class GLES20Canvas extends HardwareCanvas { nResume(mRenderer); } - private static native void nInterrupt(int renderer); - private static native void nResume(int renderer); + private static native void nInterrupt(long renderer); + private static native void nResume(long renderer); /////////////////////////////////////////////////////////////////////////// // Support @@ -487,14 +487,14 @@ class GLES20Canvas extends HardwareCanvas { return nClipPath(mRenderer, path.mNativePath, op.nativeInt); } - private static native boolean nClipPath(int renderer, int path, int op); + private static native boolean nClipPath(long renderer, long path, int op); @Override public boolean clipRect(float left, float top, float right, float bottom) { return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt); } - private static native boolean nClipRect(int renderer, float left, float top, + private static native boolean nClipRect(long renderer, float left, float top, float right, float bottom, int op); @Override @@ -507,7 +507,7 @@ class GLES20Canvas extends HardwareCanvas { return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt); } - private static native boolean nClipRect(int renderer, int left, int top, + private static native boolean nClipRect(long renderer, int left, int top, int right, int bottom, int op); @Override @@ -542,21 +542,21 @@ class GLES20Canvas extends HardwareCanvas { return nClipRegion(mRenderer, region.mNativeRegion, op.nativeInt); } - private static native boolean nClipRegion(int renderer, int region, int op); + private static native boolean nClipRegion(long renderer, long region, int op); @Override public boolean getClipBounds(Rect bounds) { return nGetClipBounds(mRenderer, bounds); } - private static native boolean nGetClipBounds(int renderer, Rect bounds); + private static native boolean nGetClipBounds(long renderer, Rect bounds); @Override public boolean quickReject(float left, float top, float right, float bottom, EdgeType type) { return nQuickReject(mRenderer, left, top, right, bottom); } - private static native boolean nQuickReject(int renderer, float left, float top, + private static native boolean nQuickReject(long renderer, float left, float top, float right, float bottom); @Override @@ -581,35 +581,35 @@ class GLES20Canvas extends HardwareCanvas { if (dx != 0.0f || dy != 0.0f) nTranslate(mRenderer, dx, dy); } - private static native void nTranslate(int renderer, float dx, float dy); + private static native void nTranslate(long renderer, float dx, float dy); @Override public void skew(float sx, float sy) { nSkew(mRenderer, sx, sy); } - private static native void nSkew(int renderer, float sx, float sy); + private static native void nSkew(long renderer, float sx, float sy); @Override public void rotate(float degrees) { nRotate(mRenderer, degrees); } - private static native void nRotate(int renderer, float degrees); + private static native void nRotate(long renderer, float degrees); @Override public void scale(float sx, float sy) { nScale(mRenderer, sx, sy); } - private static native void nScale(int renderer, float sx, float sy); + private static native void nScale(long renderer, float sx, float sy); @Override public void setMatrix(Matrix matrix) { nSetMatrix(mRenderer, matrix == null ? 0 : matrix.native_instance); } - private static native void nSetMatrix(int renderer, int matrix); + private static native void nSetMatrix(long renderer, long matrix); @SuppressWarnings("deprecation") @Override @@ -617,14 +617,14 @@ class GLES20Canvas extends HardwareCanvas { nGetMatrix(mRenderer, matrix.native_instance); } - private static native void nGetMatrix(int renderer, int matrix); + private static native void nGetMatrix(long renderer, long matrix); @Override public void concat(Matrix matrix) { if (matrix != null) nConcatMatrix(mRenderer, matrix.native_instance); } - private static native void nConcatMatrix(int renderer, int matrix); + private static native void nConcatMatrix(long renderer, long matrix); /////////////////////////////////////////////////////////////////////////// // State management @@ -640,7 +640,7 @@ class GLES20Canvas extends HardwareCanvas { return nSave(mRenderer, saveFlags); } - private static native int nSave(int renderer, int flags); + private static native int nSave(long renderer, int flags); @Override public int saveLayer(RectF bounds, Paint paint, int saveFlags) { @@ -651,7 +651,7 @@ class GLES20Canvas extends HardwareCanvas { int count; int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; count = nSaveLayer(mRenderer, nativePaint, saveFlags); } finally { if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier); @@ -659,7 +659,7 @@ class GLES20Canvas extends HardwareCanvas { return count; } - private static native int nSaveLayer(int renderer, int paint, int saveFlags); + private static native int nSaveLayer(long renderer, long paint, int saveFlags); @Override public int saveLayer(float left, float top, float right, float bottom, Paint paint, @@ -668,7 +668,7 @@ class GLES20Canvas extends HardwareCanvas { int count; int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; count = nSaveLayer(mRenderer, left, top, right, bottom, nativePaint, saveFlags); } finally { if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier); @@ -678,8 +678,8 @@ class GLES20Canvas extends HardwareCanvas { return save(saveFlags); } - private static native int nSaveLayer(int renderer, float left, float top, - float right, float bottom, int paint, int saveFlags); + private static native int nSaveLayer(long renderer, float left, float top, + float right, float bottom, long paint, int saveFlags); @Override public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) { @@ -690,7 +690,7 @@ class GLES20Canvas extends HardwareCanvas { return nSaveLayerAlpha(mRenderer, alpha, saveFlags); } - private static native int nSaveLayerAlpha(int renderer, int alpha, int saveFlags); + private static native int nSaveLayerAlpha(long renderer, int alpha, int saveFlags); @Override public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, @@ -701,7 +701,7 @@ class GLES20Canvas extends HardwareCanvas { return save(saveFlags); } - private static native int nSaveLayerAlpha(int renderer, float left, float top, float right, + private static native int nSaveLayerAlpha(long renderer, float left, float top, float right, float bottom, int alpha, int saveFlags); @Override @@ -709,21 +709,21 @@ class GLES20Canvas extends HardwareCanvas { nRestore(mRenderer); } - private static native void nRestore(int renderer); + private static native void nRestore(long renderer); @Override public void restoreToCount(int saveCount) { nRestoreToCount(mRenderer, saveCount); } - private static native void nRestoreToCount(int renderer, int saveCount); + private static native void nRestoreToCount(long renderer, int saveCount); @Override public int getSaveCount() { return nGetSaveCount(mRenderer); } - private static native int nGetSaveCount(int renderer); + private static native int nGetSaveCount(long renderer); /////////////////////////////////////////////////////////////////////////// // Filtering @@ -740,8 +740,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nResetPaintFilter(int renderer); - private static native void nSetupPaintFilter(int renderer, int clearBits, int setBits); + private static native void nResetPaintFilter(long renderer); + private static native void nSetupPaintFilter(long renderer, int clearBits, int setBits); @Override public DrawFilter getDrawFilter() { @@ -764,9 +764,9 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawArc(int renderer, float left, float top, + private static native void nDrawArc(long renderer, float left, float top, float right, float bottom, float startAngle, float sweepAngle, - boolean useCenter, int paint); + boolean useCenter, long paint); @Override public void drawARGB(int a, int r, int g, int b) { @@ -780,7 +780,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing patches int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawPatch(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, patch.mNativeChunk, dst.left, dst.top, dst.right, dst.bottom, nativePaint); } finally { @@ -795,7 +795,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing patches int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawPatch(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, patch.mNativeChunk, dst.left, dst.top, dst.right, dst.bottom, nativePaint); } finally { @@ -803,8 +803,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPatch(int renderer, int bitmap, byte[] buffer, int chunk, - float left, float top, float right, float bottom, int paint); + private static native void nDrawPatch(long renderer, long bitmap, byte[] buffer, long chunk, + float left, float top, float right, float bottom, long paint); @Override public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) { @@ -812,15 +812,15 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, nativePaint); } finally { if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); } } - private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer, - float left, float top, int paint); + private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer, + float left, float top, long paint); @Override public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) { @@ -828,7 +828,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, matrix.native_instance, nativePaint); } finally { @@ -836,8 +836,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer, - int matrix, int paint); + private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer, + long matrix, long paint); @Override public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) { @@ -845,7 +845,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; int left, top, right, bottom; if (src == null) { @@ -872,7 +872,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; float left, top, right, bottom; if (src == null) { @@ -893,9 +893,9 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer, + private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer, float srcLeft, float srcTop, float srcRight, float srcBottom, - float left, float top, float right, float bottom, int paint); + float left, float top, float right, float bottom, long paint); @Override public void drawBitmap(int[] colors, int offset, int stride, float x, float y, @@ -923,7 +923,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawBitmap(mRenderer, colors, offset, stride, x, y, width, height, hasAlpha, nativePaint); } finally { @@ -931,8 +931,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawBitmap(int renderer, int[] colors, int offset, int stride, - float x, float y, int width, int height, boolean hasAlpha, int nativePaint); + private static native void nDrawBitmap(long renderer, int[] colors, int offset, int stride, + float x, float y, int width, int height, boolean hasAlpha, long nativePaint); @Override public void drawBitmap(int[] colors, int offset, int stride, int x, int y, @@ -962,7 +962,7 @@ class GLES20Canvas extends HardwareCanvas { int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawBitmapMesh(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, meshWidth, meshHeight, verts, vertOffset, colors, colorOffset, nativePaint); } finally { @@ -970,9 +970,9 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawBitmapMesh(int renderer, int bitmap, byte[] buffer, + private static native void nDrawBitmapMesh(long renderer, long bitmap, byte[] buffer, int meshWidth, int meshHeight, float[] verts, int vertOffset, - int[] colors, int colorOffset, int paint); + int[] colors, int colorOffset, long paint); @Override public void drawCircle(float cx, float cy, float radius, Paint paint) { @@ -984,8 +984,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawCircle(int renderer, float cx, float cy, - float radius, int paint); + private static native void nDrawCircle(long renderer, float cx, float cy, + float radius, long paint); @Override public void drawColor(int color) { @@ -997,7 +997,7 @@ class GLES20Canvas extends HardwareCanvas { nDrawColor(mRenderer, color, mode.nativeInt); } - private static native void nDrawColor(int renderer, int color, int mode); + private static native void nDrawColor(long renderer, int color, int mode); @Override public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) { @@ -1024,8 +1024,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawLines(int renderer, float[] points, - int offset, int count, int paint); + private static native void nDrawLines(long renderer, float[] points, + int offset, int count, long paint); @Override public void drawLines(float[] pts, Paint paint) { @@ -1042,8 +1042,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawOval(int renderer, float left, float top, - float right, float bottom, int paint); + private static native void nDrawOval(long renderer, float left, float top, + float right, float bottom, long paint); @Override public void drawPaint(Paint paint) { @@ -1068,8 +1068,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPath(int renderer, int path, int paint); - private static native void nDrawRects(int renderer, int region, int paint); + private static native void nDrawPath(long renderer, long path, long paint); + private static native void nDrawRects(long renderer, long region, long paint); void drawRects(float[] rects, int count, Paint paint) { int modifiers = setupModifiers(paint, MODIFIER_COLOR_FILTER | MODIFIER_SHADER); @@ -1080,7 +1080,7 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawRects(int renderer, float[] rects, int count, int paint); + private static native void nDrawRects(long renderer, float[] rects, int count, long paint); @Override public void drawPicture(Picture picture) { @@ -1147,8 +1147,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPoints(int renderer, float[] points, - int offset, int count, int paint); + private static native void nDrawPoints(long renderer, float[] points, + int offset, int count, long paint); @SuppressWarnings("deprecation") @Override @@ -1165,8 +1165,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPosText(int renderer, char[] text, int index, int count, - float[] pos, int paint); + private static native void nDrawPosText(long renderer, char[] text, int index, int count, + float[] pos, long paint); @SuppressWarnings("deprecation") @Override @@ -1183,8 +1183,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPosText(int renderer, String text, int start, int end, - float[] pos, int paint); + private static native void nDrawPosText(long renderer, String text, int start, int end, + float[] pos, long paint); @Override public void drawRect(float left, float top, float right, float bottom, Paint paint) { @@ -1197,8 +1197,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawRect(int renderer, float left, float top, - float right, float bottom, int paint); + private static native void nDrawRect(long renderer, float left, float top, + float right, float bottom, long paint); @Override public void drawRect(Rect r, Paint paint) { @@ -1226,8 +1226,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawRoundRect(int renderer, float left, float top, - float right, float bottom, float rx, float y, int paint); + private static native void nDrawRoundRect(long renderer, float left, float top, + float right, float bottom, float rx, float y, long paint); @Override public void drawText(char[] text, int index, int count, float x, float y, Paint paint) { @@ -1243,8 +1243,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawText(int renderer, char[] text, int index, int count, - float x, float y, int bidiFlags, int paint); + private static native void nDrawText(long renderer, char[] text, int index, int count, + float x, float y, int bidiFlags, long paint); @Override public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) { @@ -1283,8 +1283,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawText(int renderer, String text, int start, int end, - float x, float y, int bidiFlags, int paint); + private static native void nDrawText(long renderer, String text, int start, int end, + float x, float y, int bidiFlags, long paint); @Override public void drawText(String text, float x, float y, Paint paint) { @@ -1313,8 +1313,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawTextOnPath(int renderer, char[] text, int index, int count, - int path, float hOffset, float vOffset, int bidiFlags, int nativePaint); + private static native void nDrawTextOnPath(long renderer, char[] text, int index, int count, + long path, float hOffset, float vOffset, int bidiFlags, long nativePaint); @Override public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) { @@ -1329,8 +1329,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawTextOnPath(int renderer, String text, int start, int end, - int path, float hOffset, float vOffset, int bidiFlags, int nativePaint); + private static native void nDrawTextOnPath(long renderer, String text, int start, int end, + long path, float hOffset, float vOffset, int bidiFlags, long nativePaint); @Override public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount, @@ -1351,8 +1351,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawTextRun(int renderer, char[] text, int index, int count, - int contextIndex, int contextCount, float x, float y, int dir, int nativePaint); + private static native void nDrawTextRun(long renderer, char[] text, int index, int count, + int contextIndex, int contextCount, float x, float y, int dir, long nativePaint); @Override public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd, @@ -1385,8 +1385,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawTextRun(int renderer, String text, int start, int end, - int contextStart, int contextEnd, float x, float y, int flags, int nativePaint); + private static native void nDrawTextRun(long renderer, String text, int start, int end, + int contextStart, int contextEnd, float x, float y, int flags, long nativePaint); @Override public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset, @@ -1466,10 +1466,10 @@ class GLES20Canvas extends HardwareCanvas { return MODIFIER_NONE; } - private static native void nSetupShader(int renderer, int shader); - private static native void nSetupColorFilter(int renderer, int colorFilter); - private static native void nSetupShadow(int renderer, float radius, + private static native void nSetupShader(long renderer, long shader); + private static native void nSetupColorFilter(long renderer, long colorFilter); + private static native void nSetupShadow(long renderer, float radius, float dx, float dy, int color); - private static native void nResetModifiers(int renderer, int modifiers); + private static native void nResetModifiers(long renderer, int modifiers); } diff --git a/core/java/android/view/GLES20DisplayList.java b/core/java/android/view/GLES20DisplayList.java index c652bac..7f8b3bd 100644 --- a/core/java/android/view/GLES20DisplayList.java +++ b/core/java/android/view/GLES20DisplayList.java @@ -44,7 +44,7 @@ class GLES20DisplayList extends DisplayList { return mValid && mFinalizer != null; } - int getNativeDisplayList() { + long getNativeDisplayList() { if (!mValid || mFinalizer == null) { throw new IllegalStateException("The display list is not valid."); } @@ -124,9 +124,9 @@ class GLES20DisplayList extends DisplayList { return nGetDisplayListSize(mFinalizer.mNativeDisplayList); } - private static native void nDestroyDisplayList(int displayList); - private static native int nGetDisplayListSize(int displayList); - private static native void nSetDisplayListName(int displayList, String name); + private static native void nDestroyDisplayList(long displayList); + private static native int nGetDisplayListSize(long displayList); + private static native void nSetDisplayListName(long displayList, String name); /////////////////////////////////////////////////////////////////////////// // Native View Properties @@ -440,62 +440,62 @@ class GLES20DisplayList extends DisplayList { } } - private static native void nReset(int displayList); - private static native void nOffsetTopAndBottom(int displayList, float offset); - private static native void nOffsetLeftAndRight(int displayList, float offset); - private static native void nSetLeftTopRightBottom(int displayList, int left, int top, + private static native void nReset(long displayList); + private static native void nOffsetTopAndBottom(long displayList, float offset); + private static native void nOffsetLeftAndRight(long displayList, float offset); + private static native void nSetLeftTopRightBottom(long displayList, int left, int top, int right, int bottom); - private static native void nSetBottom(int displayList, int bottom); - private static native void nSetRight(int displayList, int right); - private static native void nSetTop(int displayList, int top); - private static native void nSetLeft(int displayList, int left); - private static native void nSetCameraDistance(int displayList, float distance); - private static native void nSetPivotY(int displayList, float pivotY); - private static native void nSetPivotX(int displayList, float pivotX); - private static native void nSetCaching(int displayList, boolean caching); - private static native void nSetClipToBounds(int displayList, boolean clipToBounds); - private static native void nSetAlpha(int displayList, float alpha); - private static native void nSetHasOverlappingRendering(int displayList, + private static native void nSetBottom(long displayList, int bottom); + private static native void nSetRight(long displayList, int right); + private static native void nSetTop(long displayList, int top); + private static native void nSetLeft(long displayList, int left); + private static native void nSetCameraDistance(long displayList, float distance); + private static native void nSetPivotY(long displayList, float pivotY); + private static native void nSetPivotX(long displayList, float pivotX); + private static native void nSetCaching(long displayList, boolean caching); + private static native void nSetClipToBounds(long displayList, boolean clipToBounds); + private static native void nSetAlpha(long displayList, float alpha); + private static native void nSetHasOverlappingRendering(long displayList, boolean hasOverlappingRendering); - private static native void nSetTranslationX(int displayList, float translationX); - private static native void nSetTranslationY(int displayList, float translationY); - private static native void nSetRotation(int displayList, float rotation); - private static native void nSetRotationX(int displayList, float rotationX); - private static native void nSetRotationY(int displayList, float rotationY); - private static native void nSetScaleX(int displayList, float scaleX); - private static native void nSetScaleY(int displayList, float scaleY); - private static native void nSetTransformationInfo(int displayList, float alpha, + private static native void nSetTranslationX(long displayList, float translationX); + private static native void nSetTranslationY(long displayList, float translationY); + private static native void nSetRotation(long displayList, float rotation); + private static native void nSetRotationX(long displayList, float rotationX); + private static native void nSetRotationY(long displayList, float rotationY); + private static native void nSetScaleX(long displayList, float scaleX); + private static native void nSetScaleY(long displayList, float scaleY); + private static native void nSetTransformationInfo(long displayList, float alpha, float translationX, float translationY, float rotation, float rotationX, float rotationY, float scaleX, float scaleY); - private static native void nSetStaticMatrix(int displayList, int nativeMatrix); - private static native void nSetAnimationMatrix(int displayList, int animationMatrix); - - private static native boolean nHasOverlappingRendering(int displayList); - private static native void nGetMatrix(int displayList, int matrix); - private static native float nGetAlpha(int displayList); - private static native float nGetLeft(int displayList); - private static native float nGetTop(int displayList); - private static native float nGetRight(int displayList); - private static native float nGetBottom(int displayList); - private static native float nGetCameraDistance(int displayList); - private static native float nGetScaleX(int displayList); - private static native float nGetScaleY(int displayList); - private static native float nGetTranslationX(int displayList); - private static native float nGetTranslationY(int displayList); - private static native float nGetRotation(int displayList); - private static native float nGetRotationX(int displayList); - private static native float nGetRotationY(int displayList); - private static native float nGetPivotX(int displayList); - private static native float nGetPivotY(int displayList); + private static native void nSetStaticMatrix(long displayList, long nativeMatrix); + private static native void nSetAnimationMatrix(long displayList, long animationMatrix); + + private static native boolean nHasOverlappingRendering(long displayList); + private static native void nGetMatrix(long displayList, long matrix); + private static native float nGetAlpha(long displayList); + private static native float nGetLeft(long displayList); + private static native float nGetTop(long displayList); + private static native float nGetRight(long displayList); + private static native float nGetBottom(long displayList); + private static native float nGetCameraDistance(long displayList); + private static native float nGetScaleX(long displayList); + private static native float nGetScaleY(long displayList); + private static native float nGetTranslationX(long displayList); + private static native float nGetTranslationY(long displayList); + private static native float nGetRotation(long displayList); + private static native float nGetRotationX(long displayList); + private static native float nGetRotationY(long displayList); + private static native float nGetPivotX(long displayList); + private static native float nGetPivotY(long displayList); /////////////////////////////////////////////////////////////////////////// // Finalization /////////////////////////////////////////////////////////////////////////// private static class DisplayListFinalizer { - final int mNativeDisplayList; + final long mNativeDisplayList; - public DisplayListFinalizer(int nativeDisplayList) { + public DisplayListFinalizer(long nativeDisplayList) { mNativeDisplayList = nativeDisplayList; } diff --git a/core/java/android/view/GLES20Layer.java b/core/java/android/view/GLES20Layer.java index 0e3311c..37154eb 100644 --- a/core/java/android/view/GLES20Layer.java +++ b/core/java/android/view/GLES20Layer.java @@ -24,7 +24,7 @@ import android.graphics.Paint; * An OpenGL ES 2.0 implementation of {@link HardwareLayer}. */ abstract class GLES20Layer extends HardwareLayer { - int mLayer; + long mLayer; Finalizer mFinalizer; GLES20Layer() { @@ -39,7 +39,7 @@ abstract class GLES20Layer extends HardwareLayer { * * @return A pointer to the native layer object, or 0 if the object is NULL */ - public int getLayer() { + public long getLayer() { return mLayer; } @@ -75,9 +75,9 @@ abstract class GLES20Layer extends HardwareLayer { } static class Finalizer { - private int mLayerId; + private long mLayerId; - public Finalizer(int layerId) { + public Finalizer(long layerId) { mLayerId = layerId; } diff --git a/core/java/android/view/GLES20RecordingCanvas.java b/core/java/android/view/GLES20RecordingCanvas.java index b6fc38d..e3e1c76 100644 --- a/core/java/android/view/GLES20RecordingCanvas.java +++ b/core/java/android/view/GLES20RecordingCanvas.java @@ -58,7 +58,7 @@ class GLES20RecordingCanvas extends GLES20Canvas { mDisplayList.clearReferences(); } - int end(int nativeDisplayList) { + long end(long nativeDisplayList) { return getDisplayList(nativeDisplayList); } diff --git a/core/java/android/view/GraphicBuffer.java b/core/java/android/view/GraphicBuffer.java index 30c077c..5f2a9cd 100644 --- a/core/java/android/view/GraphicBuffer.java +++ b/core/java/android/view/GraphicBuffer.java @@ -56,7 +56,7 @@ public class GraphicBuffer implements Parcelable { private final int mFormat; private final int mUsage; // Note: do not rename, this field is used by native code - private final int mNativeObject; + private final long mNativeObject; // These two fields are only used by lock/unlockCanvas() private Canvas mCanvas; @@ -77,7 +77,7 @@ public class GraphicBuffer implements Parcelable { * @return A <code>GraphicBuffer</code> instance or null */ public static GraphicBuffer create(int width, int height, int format, int usage) { - int nativeObject = nCreateGraphicBuffer(width, height, format, usage); + long nativeObject = nCreateGraphicBuffer(width, height, format, usage); if (nativeObject != 0) { return new GraphicBuffer(width, height, format, usage, nativeObject); } @@ -87,7 +87,7 @@ public class GraphicBuffer implements Parcelable { /** * Private use only. See {@link #create(int, int, int, int)}. */ - private GraphicBuffer(int width, int height, int format, int usage, int nativeObject) { + private GraphicBuffer(int width, int height, int format, int usage, long nativeObject) { mWidth = width; mHeight = height; mFormat = format; @@ -271,7 +271,7 @@ public class GraphicBuffer implements Parcelable { int height = in.readInt(); int format = in.readInt(); int usage = in.readInt(); - int nativeObject = nReadGraphicBufferFromParcel(in); + long nativeObject = nReadGraphicBufferFromParcel(in); if (nativeObject != 0) { return new GraphicBuffer(width, height, format, usage, nativeObject); } @@ -283,10 +283,10 @@ public class GraphicBuffer implements Parcelable { } }; - private static native int nCreateGraphicBuffer(int width, int height, int format, int usage); - private static native void nDestroyGraphicBuffer(int nativeObject); - private static native void nWriteGraphicBufferToParcel(int nativeObject, Parcel dest); - private static native int nReadGraphicBufferFromParcel(Parcel in); - private static native boolean nLockCanvas(int nativeObject, Canvas canvas, Rect dirty); - private static native boolean nUnlockCanvasAndPost(int nativeObject, Canvas canvas); + private static native long nCreateGraphicBuffer(int width, int height, int format, int usage); + private static native void nDestroyGraphicBuffer(long nativeObject); + private static native void nWriteGraphicBufferToParcel(long nativeObject, Parcel dest); + private static native long nReadGraphicBufferFromParcel(Parcel in); + private static native boolean nLockCanvas(long nativeObject, Canvas canvas, Rect dirty); + private static native boolean nUnlockCanvasAndPost(long nativeObject, Canvas canvas); } diff --git a/core/java/android/view/HardwareCanvas.java b/core/java/android/view/HardwareCanvas.java index 259e1cd..10f700c 100644 --- a/core/java/android/view/HardwareCanvas.java +++ b/core/java/android/view/HardwareCanvas.java @@ -145,7 +145,7 @@ public abstract class HardwareCanvas extends Canvas { * * @hide */ - public int callDrawGLFunction(int drawGLFunction) { + public int callDrawGLFunction(long drawGLFunction) { // Noop - this is done in the display list recorder subclass return DisplayList.STATUS_DONE; } @@ -170,12 +170,12 @@ public abstract class HardwareCanvas extends Canvas { * @param functor The native functor to remove from the execution queue. * * @see #invokeFunctors(android.graphics.Rect) - * @see #callDrawGLFunction(int) - * @see #detachFunctor(int) + * @see #callDrawGLFunction(long) + * @see #detachFunctor(long) * * @hide */ - abstract void detachFunctor(int functor); + abstract void detachFunctor(long functor); /** * Attaches the specified functor to the current functor execution queue. @@ -183,12 +183,12 @@ public abstract class HardwareCanvas extends Canvas { * @param functor The native functor to add to the execution queue. * * @see #invokeFunctors(android.graphics.Rect) - * @see #callDrawGLFunction(int) - * @see #detachFunctor(int) + * @see #callDrawGLFunction(long) + * @see #detachFunctor(long) * * @hide */ - abstract void attachFunctor(int functor); + abstract void attachFunctor(long functor); /** * Indicates that the specified layer must be updated as soon as possible. diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index f215189..f09a111 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -568,7 +568,7 @@ public abstract class HardwareRenderer { * @see HardwareCanvas#callDrawGLFunction(int) * @see #attachFunctor(android.view.View.AttachInfo, int) */ - abstract void detachFunctor(int functor); + abstract void detachFunctor(long functor); /** * Schedules the specified functor in the functors execution queue. @@ -581,7 +581,7 @@ public abstract class HardwareRenderer { * * @return true if the functor was attached successfully */ - abstract boolean attachFunctor(View.AttachInfo attachInfo, int functor); + abstract boolean attachFunctor(View.AttachInfo attachInfo, long functor); /** * Initializes the hardware renderer for the specified surface and setup the @@ -1712,14 +1712,14 @@ public abstract class HardwareRenderer { } @Override - void detachFunctor(int functor) { + void detachFunctor(long functor) { if (mCanvas != null) { mCanvas.detachFunctor(functor); } } @Override - boolean attachFunctor(View.AttachInfo attachInfo, int functor) { + boolean attachFunctor(View.AttachInfo attachInfo, long functor) { if (mCanvas != null) { mCanvas.attachFunctor(functor); mFunctorsRunnable.attachInfo = attachInfo; @@ -1981,7 +1981,7 @@ public abstract class HardwareRenderer { if (atlas.isCompatible(android.os.Process.myPpid())) { GraphicBuffer buffer = atlas.getBuffer(); if (buffer != null) { - int[] map = atlas.getMap(); + long[] map = atlas.getMap(); if (map != null) { GLES20Canvas.initAtlas(buffer, map); } diff --git a/core/java/android/view/IAssetAtlas.aidl b/core/java/android/view/IAssetAtlas.aidl index 5f1e238..edce059 100644 --- a/core/java/android/view/IAssetAtlas.aidl +++ b/core/java/android/view/IAssetAtlas.aidl @@ -45,10 +45,10 @@ interface IAssetAtlas { * if the atlas is not available yet. * * Each bitmap is represented by several entries in the array: - * int0: SkBitmap*, the native bitmap object - * int1: x position - * int2: y position - * int3: rotated, 1 if the bitmap must be rotated, 0 otherwise + * long0: SkBitmap*, the native bitmap object + * long1: x position + * long2: y position + * long3: rotated, 1 if the bitmap must be rotated, 0 otherwise */ - int[] getMap(); + long[] getMap(); } diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index 1bfda2d..91645e7 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -32,19 +32,19 @@ import dalvik.system.CloseGuard; public class Surface implements Parcelable { private static final String TAG = "Surface"; - private static native int nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture) + private static native long nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture) throws OutOfResourcesException; - private static native int nativeCreateFromSurfaceControl(int surfaceControlNativeObject); + private static native long nativeCreateFromSurfaceControl(long surfaceControlNativeObject); - private static native int nativeLockCanvas(int nativeObject, Canvas canvas, Rect dirty) + private static native long nativeLockCanvas(long nativeObject, Canvas canvas, Rect dirty) throws OutOfResourcesException; - private static native void nativeUnlockCanvasAndPost(int nativeObject, Canvas canvas); + private static native void nativeUnlockCanvasAndPost(long nativeObject, Canvas canvas); - private static native void nativeRelease(int nativeObject); - private static native boolean nativeIsValid(int nativeObject); - private static native boolean nativeIsConsumerRunningBehind(int nativeObject); - private static native int nativeReadFromParcel(int nativeObject, Parcel source); - private static native void nativeWriteToParcel(int nativeObject, Parcel dest); + private static native void nativeRelease(long nativeObject); + private static native boolean nativeIsValid(long nativeObject); + private static native boolean nativeIsConsumerRunningBehind(long nativeObject); + private static native long nativeReadFromParcel(long nativeObject, Parcel source); + private static native void nativeWriteToParcel(long nativeObject, Parcel dest); public static final Parcelable.Creator<Surface> CREATOR = new Parcelable.Creator<Surface>() { @@ -71,8 +71,8 @@ public class Surface implements Parcelable { // Guarded state. final Object mLock = new Object(); // protects the native state private String mName; - int mNativeObject; // package scope only for SurfaceControl access - private int mLockedObject; + long mNativeObject; // package scope only for SurfaceControl access + private long mLockedObject; private int mGenerationId; // incremented each time mNativeObject changes private final Canvas mCanvas = new CompatibleCanvas(); @@ -130,7 +130,7 @@ public class Surface implements Parcelable { } /* called from android_view_Surface_createFromIGraphicBufferProducer() */ - private Surface(int nativeObject) { + private Surface(long nativeObject) { synchronized (mLock) { setNativeObjectLocked(nativeObject); } @@ -261,8 +261,8 @@ public class Surface implements Parcelable { checkNotReleasedLocked(); if (mNativeObject != mLockedObject) { Log.w(TAG, "WARNING: Surface's mNativeObject (0x" + - Integer.toHexString(mNativeObject) + ") != mLockedObject (0x" + - Integer.toHexString(mLockedObject) +")"); + Long.toHexString(mNativeObject) + ") != mLockedObject (0x" + + Long.toHexString(mLockedObject) +")"); } if (mLockedObject == 0) { throw new IllegalStateException("Surface was not locked"); @@ -307,12 +307,12 @@ public class Surface implements Parcelable { throw new IllegalArgumentException("other must not be null"); } - int surfaceControlPtr = other.mNativeObject; + long surfaceControlPtr = other.mNativeObject; if (surfaceControlPtr == 0) { throw new NullPointerException( "SurfaceControl native object is null. Are you using a released SurfaceControl?"); } - int newNativeObject = nativeCreateFromSurfaceControl(surfaceControlPtr); + long newNativeObject = nativeCreateFromSurfaceControl(surfaceControlPtr); synchronized (mLock) { if (mNativeObject != 0) { @@ -334,7 +334,7 @@ public class Surface implements Parcelable { throw new IllegalArgumentException("other must not be null"); } if (other != this) { - final int newPtr; + final long newPtr; synchronized (other.mLock) { newPtr = other.mNativeObject; other.setNativeObjectLocked(0); @@ -391,7 +391,7 @@ public class Surface implements Parcelable { } } - private void setNativeObjectLocked(int ptr) { + private void setNativeObjectLocked(long ptr) { if (mNativeObject != ptr) { if (mNativeObject == 0 && ptr != 0) { mCloseGuard.open("release"); diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index b22d5cf..62afa60 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -33,11 +33,11 @@ import android.view.Surface.OutOfResourcesException; public class SurfaceControl { private static final String TAG = "SurfaceControl"; - private static native int nativeCreate(SurfaceSession session, String name, + private static native long nativeCreate(SurfaceSession session, String name, int w, int h, int format, int flags) throws OutOfResourcesException; - private static native void nativeRelease(int nativeObject); - private static native void nativeDestroy(int nativeObject); + private static native void nativeRelease(long nativeObject); + private static native void nativeDestroy(long nativeObject); private static native Bitmap nativeScreenshot(IBinder displayToken, int width, int height, int minLayer, int maxLayer, boolean allLayers); @@ -48,21 +48,21 @@ public class SurfaceControl { private static native void nativeCloseTransaction(); private static native void nativeSetAnimationTransaction(); - private static native void nativeSetLayer(int nativeObject, int zorder); - private static native void nativeSetPosition(int nativeObject, float x, float y); - private static native void nativeSetSize(int nativeObject, int w, int h); - private static native void nativeSetTransparentRegionHint(int nativeObject, Region region); - private static native void nativeSetAlpha(int nativeObject, float alpha); - private static native void nativeSetMatrix(int nativeObject, float dsdx, float dtdx, float dsdy, float dtdy); - private static native void nativeSetFlags(int nativeObject, int flags, int mask); - private static native void nativeSetWindowCrop(int nativeObject, int l, int t, int r, int b); - private static native void nativeSetLayerStack(int nativeObject, int layerStack); + private static native void nativeSetLayer(long nativeObject, int zorder); + private static native void nativeSetPosition(long nativeObject, float x, float y); + private static native void nativeSetSize(long nativeObject, int w, int h); + private static native void nativeSetTransparentRegionHint(long nativeObject, Region region); + private static native void nativeSetAlpha(long nativeObject, float alpha); + private static native void nativeSetMatrix(long nativeObject, float dsdx, float dtdx, float dsdy, float dtdy); + private static native void nativeSetFlags(long nativeObject, int flags, int mask); + private static native void nativeSetWindowCrop(long nativeObject, int l, int t, int r, int b); + private static native void nativeSetLayerStack(long nativeObject, int layerStack); private static native IBinder nativeGetBuiltInDisplay(int physicalDisplayId); private static native IBinder nativeCreateDisplay(String name, boolean secure); private static native void nativeDestroyDisplay(IBinder displayToken); private static native void nativeSetDisplaySurface( - IBinder displayToken, int nativeSurfaceObject); + IBinder displayToken, long nativeSurfaceObject); private static native void nativeSetDisplayLayerStack( IBinder displayToken, int layerStack); private static native void nativeSetDisplayProjection( @@ -77,7 +77,7 @@ public class SurfaceControl { private final CloseGuard mCloseGuard = CloseGuard.get(); private final String mName; - int mNativeObject; // package visibility only for Surface.java access + long mNativeObject; // package visibility only for Surface.java access private static final boolean HEADLESS = "1".equals( SystemProperties.get("ro.config.headless", "0")); diff --git a/core/java/android/view/SurfaceSession.java b/core/java/android/view/SurfaceSession.java index 0dfd94a..3cf5af4 100644 --- a/core/java/android/view/SurfaceSession.java +++ b/core/java/android/view/SurfaceSession.java @@ -24,11 +24,11 @@ package android.view; */ public final class SurfaceSession { // Note: This field is accessed by native code. - private int mNativeClient; // SurfaceComposerClient* + private long mNativeClient; // SurfaceComposerClient* - private static native int nativeCreate(); - private static native void nativeDestroy(int ptr); - private static native void nativeKill(int ptr); + private static native long nativeCreate(); + private static native void nativeDestroy(long ptr); + private static native void nativeKill(long ptr); /** Create a new connection with the surface flinger. */ public SurfaceSession() { diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index 47f7628..b78af2e 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -127,7 +127,7 @@ public class TextureView extends View { private final Object[] mNativeWindowLock = new Object[0]; // Used from native code, do not write! @SuppressWarnings({"UnusedDeclaration"}) - private int mNativeWindow; + private long mNativeWindow; /** * Creates a new TextureView. @@ -816,6 +816,6 @@ public class TextureView extends View { private native void nCreateNativeWindow(SurfaceTexture surface); private native void nDestroyNativeWindow(); - private static native boolean nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty); - private static native void nUnlockCanvasAndPost(int nativeWindow, Canvas canvas); + private static native boolean nLockCanvas(long nativeWindow, Canvas canvas, Rect dirty); + private static native void nUnlockCanvasAndPost(long nativeWindow, Canvas canvas); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b0bae46..83610c3 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -11838,7 +11838,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * <p>Compute the vertical extent of the horizontal scrollbar's thumb + * <p>Compute the vertical extent of the vertical scrollbar's thumb * within the vertical range. This value is used to compute the length * of the thumb within the scrollbar's track.</p> * diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java index a5fad60..a06344f 100644 --- a/core/java/android/widget/AdapterView.java +++ b/core/java/android/widget/AdapterView.java @@ -663,7 +663,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup { /** * When the current adapter is empty, the AdapterView can display a special view - * call the empty view. The empty view is used to provide feedback to the user + * called the empty view. The empty view is used to provide feedback to the user * that no data is available in this AdapterView. * * @return The view to show if the adapter is empty. |
