diff options
-rw-r--r-- | core/java/android/speech/RecognizerResultsIntent.java | 17 | ||||
-rw-r--r-- | graphics/java/android/renderscript/FieldPacker.java | 125 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Matrix2f.java | 58 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Matrix3f.java | 63 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Matrix4f.java (renamed from graphics/java/android/renderscript/Matrix.java) | 33 | ||||
-rw-r--r-- | graphics/java/android/renderscript/ProgramVertex.java | 22 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Vector2f.java | 37 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Vector3f.java | 38 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Vector4f.java | 38 | ||||
-rw-r--r-- | services/java/com/android/server/BackupManagerService.java | 53 |
10 files changed, 405 insertions, 79 deletions
diff --git a/core/java/android/speech/RecognizerResultsIntent.java b/core/java/android/speech/RecognizerResultsIntent.java index 882f213..228258e 100644 --- a/core/java/android/speech/RecognizerResultsIntent.java +++ b/core/java/android/speech/RecognizerResultsIntent.java @@ -95,11 +95,11 @@ public class RecognizerResultsIntent { * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS}, if available, or else should execute a search of * its own choosing, based on the recognition result string. * - * Currently this html content should be expected in the form of an "inline:" uri for the - * Browser. In the future this may change to a "content://" uri or some other identifier. - * Anyone who reads this extra should confirm that a result is in fact an "inline:" uri and - * back off to the urls or strings gracefully if it is not, thus maintaining future backwards - * compatibility if this changes. + * Currently this html content should be expected in the form of a uri with scheme + * {@link #URI_SCHEME_INLINE} for the Browser. In the future this may change to a "content://" + * uri or some other identifier. Anyone who reads this extra should confirm that a result is + * in fact an "inline:" uri and back off to the urls or strings gracefully if it is not, thus + * maintaining future backwards compatibility if this changes. * * @hide not to be exposed immediately as the implementation details may change */ @@ -119,4 +119,11 @@ public class RecognizerResultsIntent { */ public static final String EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS = "android.speech.extras.VOICE_SEARCH_RESULT_HTML_BASE_URLS"; + + /** + * The scheme used currently for html content in {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}. + * + * @hide not to be exposed immediately as the implementation details may change + */ + public static final String URI_SCHEME_INLINE = "inline"; } diff --git a/graphics/java/android/renderscript/FieldPacker.java b/graphics/java/android/renderscript/FieldPacker.java new file mode 100644 index 0000000..fc79caf --- /dev/null +++ b/graphics/java/android/renderscript/FieldPacker.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2008 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.renderscript; + + +public class FieldPacker { + public FieldPacker(int len) { + mPos = 0; + mData = new byte[len]; + } + + public void align(int v) { + while ((mPos & (v - 1)) != 0) { + mData[mPos++] = 0; + } + } + + void reset() { + mPos = 0; + } + + void addI8(byte v) { + mData[mPos++] = v; + } + + void addI16(short v) { + align(2); + mData[mPos++] = (byte)(v & 0xff); + mData[mPos++] = (byte)(v >> 8); + } + + void addI32(int v) { + align(4); + mData[mPos++] = (byte)(v & 0xff); + mData[mPos++] = (byte)((v >> 8) & 0xff); + mData[mPos++] = (byte)((v >> 16) & 0xff); + mData[mPos++] = (byte)((v >> 24) & 0xff); + } + + void addI64(long v) { + align(8); + mData[mPos++] = (byte)(v & 0xff); + mData[mPos++] = (byte)((v >> 8) & 0xff); + mData[mPos++] = (byte)((v >> 16) & 0xff); + mData[mPos++] = (byte)((v >> 24) & 0xff); + mData[mPos++] = (byte)((v >> 32) & 0xff); + mData[mPos++] = (byte)((v >> 40) & 0xff); + mData[mPos++] = (byte)((v >> 48) & 0xff); + mData[mPos++] = (byte)((v >> 56) & 0xff); + } + + void addU8(short v) { + if ((v < 0) || (v > 0xff)) { + throw new IllegalArgumentException("Saving value out of range for type"); + } + mData[mPos++] = (byte)v; + } + + void addU16(int v) { + if ((v < 0) || (v > 0xffff)) { + throw new IllegalArgumentException("Saving value out of range for type"); + } + align(2); + mData[mPos++] = (byte)(v & 0xff); + mData[mPos++] = (byte)(v >> 8); + } + + void addU32(long v) { + if ((v < 0) || (v > 0xffffffff)) { + throw new IllegalArgumentException("Saving value out of range for type"); + } + align(4); + mData[mPos++] = (byte)(v & 0xff); + mData[mPos++] = (byte)((v >> 8) & 0xff); + mData[mPos++] = (byte)((v >> 16) & 0xff); + mData[mPos++] = (byte)((v >> 24) & 0xff); + } + + void addU64(long v) { + if (v < 0) { + throw new IllegalArgumentException("Saving value out of range for type"); + } + align(8); + mData[mPos++] = (byte)(v & 0xff); + mData[mPos++] = (byte)((v >> 8) & 0xff); + mData[mPos++] = (byte)((v >> 16) & 0xff); + mData[mPos++] = (byte)((v >> 24) & 0xff); + mData[mPos++] = (byte)((v >> 32) & 0xff); + mData[mPos++] = (byte)((v >> 40) & 0xff); + mData[mPos++] = (byte)((v >> 48) & 0xff); + mData[mPos++] = (byte)((v >> 56) & 0xff); + } + + void addF32(float v) { + addI32(Float.floatToRawIntBits(v)); + } + + void addF64(float v) { + addI64(Double.doubleToRawLongBits(v)); + } + + final byte[] getData() { + return mData; + } + + private final byte mData[]; + private int mPos; + +} + + diff --git a/graphics/java/android/renderscript/Matrix2f.java b/graphics/java/android/renderscript/Matrix2f.java new file mode 100644 index 0000000..4b5e61b --- /dev/null +++ b/graphics/java/android/renderscript/Matrix2f.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 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.renderscript; + +import java.lang.Math; +import android.util.Log; + + +/** + * @hide + * + **/ +public class Matrix2f { + + public Matrix2f() { + mMat = new float[4]; + loadIdentity(); + } + + public float get(int i, int j) { + return mMat[i*2 + j]; + } + + public void set(int i, int j, float v) { + mMat[i*2 + j] = v; + } + + public void loadIdentity() { + mMat[0] = 1; + mMat[1] = 0; + + mMat[2] = 0; + mMat[3] = 1; + } + + public void load(Matrix2f src) { + System.arraycopy(mMat, 0, src, 0, 4); + } + + final float[] mMat; +} + + + diff --git a/graphics/java/android/renderscript/Matrix3f.java b/graphics/java/android/renderscript/Matrix3f.java new file mode 100644 index 0000000..19d7b43 --- /dev/null +++ b/graphics/java/android/renderscript/Matrix3f.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2009 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.renderscript; + +import java.lang.Math; +import android.util.Log; + + +/** + * @hide + * + **/ +public class Matrix3f { + + public Matrix3f() { + mMat = new float[9]; + loadIdentity(); + } + + public float get(int i, int j) { + return mMat[i*3 + j]; + } + + public void set(int i, int j, float v) { + mMat[i*3 + j] = v; + } + + public void loadIdentity() { + mMat[0] = 1; + mMat[1] = 0; + mMat[2] = 0; + + mMat[3] = 0; + mMat[4] = 1; + mMat[5] = 0; + + mMat[6] = 0; + mMat[7] = 0; + mMat[8] = 1; + } + + public void load(Matrix3f src) { + System.arraycopy(mMat, 0, src, 0, 9); + } + + final float[] mMat; +} + + diff --git a/graphics/java/android/renderscript/Matrix.java b/graphics/java/android/renderscript/Matrix4f.java index a266d6b..ebd5bde 100644 --- a/graphics/java/android/renderscript/Matrix.java +++ b/graphics/java/android/renderscript/Matrix4f.java @@ -24,9 +24,9 @@ import android.util.Log; * @hide * **/ -public class Matrix { +public class Matrix4f { - public Matrix() { + public Matrix4f() { mMat = new float[16]; loadIdentity(); } @@ -49,7 +49,7 @@ public class Matrix { mMat[5] = 1; mMat[6] = 0; mMat[7] = 0; - + mMat[8] = 0; mMat[9] = 0; mMat[10] = 1; @@ -61,8 +61,8 @@ public class Matrix { mMat[15] = 1; } - public void load(Matrix src) { - mMat = src.mMat; + public void load(Matrix4f src) { + System.arraycopy(mMat, 0, src, 0, 16); } public void loadRotate(float rot, float x, float y, float z) { @@ -77,7 +77,7 @@ public class Matrix { rot *= (float)(java.lang.Math.PI / 180.0f); c = (float)java.lang.Math.cos(rot); s = (float)java.lang.Math.sin(rot); - + float len = (float)java.lang.Math.sqrt(x*x + y*y + z*z); if (!(len != 1)) { float recipLen = 1.f / len; @@ -91,7 +91,7 @@ public class Matrix { float zx = z * x; float xs = x * s; float ys = y * s; - float zs = z * s; + float zs = z * s; mMat[ 0] = x*x*nc + c; mMat[ 4] = xy*nc - zs; mMat[ 8] = zx*nc + ys; @@ -109,7 +109,7 @@ public class Matrix { mMat[5] = y; mMat[10] = z; } - + public void loadTranslate(float x, float y, float z) { loadIdentity(); mMat[12] = x; @@ -117,7 +117,7 @@ public class Matrix { mMat[14] = z; } - public void loadMultiply(Matrix lhs, Matrix rhs) { + public void loadMultiply(Matrix4f lhs, Matrix4f rhs) { for (int i=0 ; i<4 ; i++) { float ri0 = 0; float ri1 = 0; @@ -159,31 +159,28 @@ public class Matrix { mMat[15]= 0; } - public void multiply(Matrix rhs) { - Matrix tmp = new Matrix(); + public void multiply(Matrix4f rhs) { + Matrix4f tmp = new Matrix4f(); tmp.loadMultiply(this, rhs); load(tmp); } public void rotate(float rot, float x, float y, float z) { - Matrix tmp = new Matrix(); + Matrix4f tmp = new Matrix4f(); tmp.loadRotate(rot, x, y, z); multiply(tmp); } public void scale(float x, float y, float z) { - Matrix tmp = new Matrix(); + Matrix4f tmp = new Matrix4f(); tmp.loadScale(x, y, z); multiply(tmp); } public void translate(float x, float y, float z) { - Matrix tmp = new Matrix(); + Matrix4f tmp = new Matrix4f(); tmp.loadTranslate(x, y, z); multiply(tmp); } - - - float[] mMat; - + final float[] mMat; } diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java index 84f6f2d..1b155d7 100644 --- a/graphics/java/android/renderscript/ProgramVertex.java +++ b/graphics/java/android/renderscript/ProgramVertex.java @@ -96,16 +96,16 @@ public class ProgramVertex extends Program { static final int PROJECTION_OFFSET = 16; static final int TEXTURE_OFFSET = 32; - Matrix mModel; - Matrix mProjection; - Matrix mTexture; + Matrix4f mModel; + Matrix4f mProjection; + Matrix4f mTexture; public Allocation mAlloc; public MatrixAllocation(RenderScript rs) { - mModel = new Matrix(); - mProjection = new Matrix(); - mTexture = new Matrix(); + mModel = new Matrix4f(); + mProjection = new Matrix4f(); + mTexture = new Matrix4f(); mAlloc = Allocation.createSized(rs, Element.createUser(rs, Element.DataType.FLOAT_32), 48); mAlloc.subData1D(MODELVIEW_OFFSET, 16, mModel.mMat); @@ -118,17 +118,17 @@ public class ProgramVertex extends Program { mAlloc = null; } - public void loadModelview(Matrix m) { + public void loadModelview(Matrix4f m) { mModel = m; mAlloc.subData1D(MODELVIEW_OFFSET, 16, m.mMat); } - public void loadProjection(Matrix m) { + public void loadProjection(Matrix4f m) { mProjection = m; mAlloc.subData1D(PROJECTION_OFFSET, 16, m.mMat); } - public void loadTexture(Matrix m) { + public void loadTexture(Matrix4f m) { mTexture = m; mAlloc.subData1D(TEXTURE_OFFSET, 16, m.mMat); } @@ -152,8 +152,8 @@ public class ProgramVertex extends Program { public void setupProjectionNormalized(int w, int h) { // range -1,1 in the narrow axis at z = 0. - Matrix m1 = new Matrix(); - Matrix m2 = new Matrix(); + Matrix4f m1 = new Matrix4f(); + Matrix4f m2 = new Matrix4f(); if(w > h) { float aspect = ((float)w) / h; diff --git a/graphics/java/android/renderscript/Vector2f.java b/graphics/java/android/renderscript/Vector2f.java new file mode 100644 index 0000000..567d57f --- /dev/null +++ b/graphics/java/android/renderscript/Vector2f.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2009 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.renderscript; + +import java.lang.Math; +import android.util.Log; + + +/** + * @hide + * + **/ +public class Vector2f { + public Vector2f() { + } + + public float x; + public float y; +} + + + + diff --git a/graphics/java/android/renderscript/Vector3f.java b/graphics/java/android/renderscript/Vector3f.java new file mode 100644 index 0000000..f2842f3 --- /dev/null +++ b/graphics/java/android/renderscript/Vector3f.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2009 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.renderscript; + +import java.lang.Math; +import android.util.Log; + + +/** + * @hide + * + **/ +public class Vector3f { + public Vector3f() { + } + + public float x; + public float y; + public float z; +} + + + + diff --git a/graphics/java/android/renderscript/Vector4f.java b/graphics/java/android/renderscript/Vector4f.java new file mode 100644 index 0000000..fabd959 --- /dev/null +++ b/graphics/java/android/renderscript/Vector4f.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2009 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.renderscript; + +import java.lang.Math; +import android.util.Log; + + +/** + * @hide + * + **/ +public class Vector4f { + public Vector4f() { + } + + public float x; + public float y; + public float z; + public float w; +} + + + diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 62dcb08..ef184d2 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -157,7 +157,6 @@ class BackupManagerService extends IBackupManager.Stub { final Object mAgentConnectLock = new Object(); IBackupAgent mConnectedAgent; volatile boolean mConnecting; - volatile boolean mBackupOrRestoreInProgress = false; volatile long mLastBackupPass; volatile long mNextBackupPass; @@ -217,7 +216,6 @@ class BackupManagerService extends IBackupManager.Stub { // Persistently track the need to do a full init static final String INIT_SENTINEL_FILE_NAME = "_need_init_"; HashSet<String> mPendingInits = new HashSet<String>(); // transport names - volatile boolean mInitInProgress = false; // ----- Asynchronous backup/restore handler thread ----- @@ -237,9 +235,6 @@ class BackupManagerService extends IBackupManager.Stub { IBackupTransport transport = getTransport(mCurrentTransport); if (transport == null) { Log.v(TAG, "Backup requested but no transport available"); - synchronized (mQueueLock) { - mBackupOrRestoreInProgress = false; - } mWakelock.release(); break; } @@ -267,9 +262,6 @@ class BackupManagerService extends IBackupManager.Stub { (new PerformBackupTask(transport, queue, oldJournal)).run(); } else { Log.v(TAG, "Backup requested but nothing pending"); - synchronized (mQueueLock) { - mBackupOrRestoreInProgress = false; - } mWakelock.release(); } } @@ -440,13 +432,10 @@ class BackupManagerService extends IBackupManager.Stub { // can't really do more than bail here } } else { - // Don't run backups now if we're disabled, not yet - // fully set up, in the middle of a backup already, - // or racing with an initialize pass. - if (mEnabled && mProvisioned - && !mBackupOrRestoreInProgress && !mInitInProgress) { + // Don't run backups now if we're disabled or not yet + // fully set up. + if (mEnabled && mProvisioned) { if (DEBUG) Log.v(TAG, "Running a backup pass"); - mBackupOrRestoreInProgress = true; // Acquire the wakelock and pass it to the backup thread. it will // be released once backup concludes. @@ -455,8 +444,7 @@ class BackupManagerService extends IBackupManager.Stub { Message msg = mBackupHandler.obtainMessage(MSG_RUN_BACKUP); mBackupHandler.sendMessage(msg); } else { - Log.w(TAG, "Backup pass but e=" + mEnabled + " p=" + mProvisioned - + " b=" + mBackupOrRestoreInProgress + " i=" + mInitInProgress); + Log.w(TAG, "Backup pass but e=" + mEnabled + " p=" + mProvisioned); } } } @@ -469,7 +457,6 @@ class BackupManagerService extends IBackupManager.Stub { if (RUN_INITIALIZE_ACTION.equals(intent.getAction())) { synchronized (mQueueLock) { if (DEBUG) Log.v(TAG, "Running a device init"); - mInitInProgress = true; // Acquire the wakelock and pass it to the init thread. it will // be released once init concludes. @@ -1133,7 +1120,7 @@ class BackupManagerService extends IBackupManager.Stub { if (status == BackupConstants.TRANSPORT_NOT_INITIALIZED) { // The backend reports that our dataset has been wiped. We need to // reset all of our bookkeeping and instead run a new backup pass for - // everything. This must come after mBackupOrRestoreInProgress is cleared. + // everything. EventLog.writeEvent(EventLogTags.BACKUP_RESET, mTransport.transportDirName()); resetBackupState(mStateDir); } @@ -1166,14 +1153,8 @@ class BackupManagerService extends IBackupManager.Stub { Log.e(TAG, "Unable to remove backup journal file " + mJournal); } - // Only once we're entirely finished do we indicate our completion - // and release the wakelock - synchronized (mQueueLock) { - mBackupOrRestoreInProgress = false; - } - + // Only once we're entirely finished do we release the wakelock if (status == BackupConstants.TRANSPORT_NOT_INITIALIZED) { - // This must come after mBackupOrRestoreInProgress is cleared. backupNow(); } @@ -1635,9 +1616,6 @@ class BackupManagerService extends IBackupManager.Stub { } // done; we can finally release the wakelock - synchronized (mQueueLock) { - mBackupOrRestoreInProgress = false; - } mWakelock.release(); } } @@ -1762,9 +1740,6 @@ class BackupManagerService extends IBackupManager.Stub { } // Last but not least, release the cpu - synchronized (mQueueLock) { - mBackupOrRestoreInProgress = false; - } mWakelock.release(); } } @@ -1826,10 +1801,7 @@ class BackupManagerService extends IBackupManager.Stub { } catch (Exception e) { Log.e(TAG, "Unexpected error performing init", e); } finally { - // Done; indicate that we're finished and release the wakelock - synchronized (mQueueLock) { - mInitInProgress = false; - } + // Done; release the wakelock mWakelock.release(); } } @@ -2220,16 +2192,9 @@ class BackupManagerService extends IBackupManager.Stub { } synchronized (mQueueLock) { - if (mBackupOrRestoreInProgress) { - Log.e(TAG, "Backup pass in progress, restore aborted"); - return -1; - } - for (int i = 0; i < mRestoreSets.length; i++) { if (token == mRestoreSets[i].token) { long oldId = Binder.clearCallingIdentity(); - // Suppress backups until the restore operation is finished - mBackupOrRestoreInProgress = true; mWakelock.acquire(); Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE); msg.obj = new RestoreParams(mRestoreTransport, observer, token); @@ -2276,9 +2241,7 @@ class BackupManagerService extends IBackupManager.Stub { synchronized (mQueueLock) { pw.println("Backup Manager is " + (mEnabled ? "enabled" : "disabled") + " / " + (!mProvisioned ? "not " : "") + "provisioned / " - + (!mBackupOrRestoreInProgress ? "not " : "") + "in progress / " - + (this.mPendingInits.size() == 0 ? "not " : "") + "pending init / " - + (!mInitInProgress ? "not " : "") + "initializing"); + + (this.mPendingInits.size() == 0 ? "not " : "") + "pending init"); pw.println("Last backup pass: " + mLastBackupPass + " (now = " + System.currentTimeMillis() + ')'); pw.println(" next scheduled: " + mNextBackupPass); |