Loading camera/libcameraservice/CameraService.cpp +43 −28 Original line number Diff line number Diff line Loading @@ -683,6 +683,8 @@ void CameraService::Client::stopPreview() { LOGD("stopPreview (pid %d)", getCallingPid()); // hold main lock during state transition { Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; Loading @@ -698,14 +700,22 @@ void CameraService::Client::stopPreview() if (mSurface != 0 && !mUseOverlay) { mSurface->unregisterBuffers(); } } // hold preview buffer lock { Mutex::Autolock lock(mPreviewLock); mPreviewBuffer.clear(); } } // stop recording mode void CameraService::Client::stopRecording() { LOGD("stopRecording (pid %d)", getCallingPid()); // hold main lock during state transition { Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; Loading @@ -722,9 +732,14 @@ void CameraService::Client::stopRecording() mHardware->stopRecording(); mHardware->disableMsgType(CAMERA_MSG_VIDEO_FRAME); LOGD("stopRecording(), hardware stopped OK"); } // hold preview buffer lock { Mutex::Autolock lock(mPreviewLock); mPreviewBuffer.clear(); } } // release a recording frame void CameraService::Client::releaseRecordingFrame(const sp<IMemory>& mem) Loading Loading @@ -1216,10 +1231,10 @@ void CameraService::Client::copyFrameAndPostCopiedFrame(const sp<ICameraClient>& // provided it's big enough. Don't allocate the memory or // perform the copy if there's no callback. // hold the lock while we grab a reference to the preview buffer // hold the preview lock while we grab a reference to the preview buffer sp<MemoryHeapBase> previewBuffer; { Mutex::Autolock lock(mLock); Mutex::Autolock lock(mPreviewLock); if (mPreviewBuffer == 0) { mPreviewBuffer = new MemoryHeapBase(size, 0, NULL); } else if (size > mPreviewBuffer->virtualSize()) { Loading camera/libcameraservice/CameraService.h +3 −1 Original line number Diff line number Diff line Loading @@ -181,7 +181,6 @@ private: mutable Condition mReady; sp<CameraService> mCameraService; sp<ISurface> mSurface; sp<MemoryHeapBase> mPreviewBuffer; int mPreviewCallbackFlag; sp<MediaPlayer> mMediaPlayerClick; Loading @@ -197,6 +196,9 @@ private: sp<OverlayRef> mOverlayRef; int mOverlayW; int mOverlayH; mutable Mutex mPreviewLock; sp<MemoryHeapBase> mPreviewBuffer; }; // ---------------------------------------------------------------------------- Loading core/java/android/accounts/AccountAuthenticatorCache.java +21 −1 Original line number Diff line number Diff line Loading @@ -18,10 +18,16 @@ package android.accounts; import android.content.pm.PackageManager; import android.content.pm.RegisteredServicesCache; import android.content.pm.XmlSerializerAndParser; import android.content.res.TypedArray; import android.content.Context; import android.util.AttributeSet; import android.text.TextUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; /** * A cache of services that export the {@link IAccountAuthenticator} interface. This cache Loading @@ -33,10 +39,12 @@ import android.text.TextUtils; /* package private */ class AccountAuthenticatorCache extends RegisteredServicesCache<AuthenticatorDescription> { private static final String TAG = "Account"; private static final MySerializer sSerializer = new MySerializer(); public AccountAuthenticatorCache(Context context) { super(context, AccountManager.ACTION_AUTHENTICATOR_INTENT, AccountManager.AUTHENTICATOR_META_DATA_NAME, AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME); AccountManager.AUTHENTICATOR_META_DATA_NAME, AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME, sSerializer); } public AuthenticatorDescription parseServiceAttributes(String packageName, AttributeSet attrs) { Loading @@ -62,4 +70,16 @@ import android.text.TextUtils; sa.recycle(); } } private static class MySerializer implements XmlSerializerAndParser<AuthenticatorDescription> { public void writeAsXml(AuthenticatorDescription item, XmlSerializer out) throws IOException { out.attribute(null, "type", item.type); } public AuthenticatorDescription createFromXml(XmlPullParser parser) throws IOException, XmlPullParserException { return AuthenticatorDescription.newKey(parser.getAttributeValue(null, "type")); } } } core/java/android/accounts/AccountManagerService.java +8 −13 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ import com.android.internal.R; */ public class AccountManagerService extends IAccountManager.Stub implements RegisteredServicesCacheListener { implements RegisteredServicesCacheListener<AuthenticatorDescription> { private static final String GOOGLE_ACCOUNT_TYPE = "com.google"; private static final String NO_BROADCAST_FLAG = "nobroadcast"; Loading Loading @@ -220,35 +220,30 @@ public class AccountManagerService mMessageHandler = new MessageHandler(mMessageThread.getLooper()); mAuthenticatorCache = new AccountAuthenticatorCache(mContext); mAuthenticatorCache.setListener(this); mAuthenticatorCache.setListener(this, null /* Handler */); mBindHelper = new AuthenticatorBindHelper(mContext, mAuthenticatorCache, mMessageHandler, MESSAGE_CONNECTED, MESSAGE_DISCONNECTED); mSimWatcher = new SimWatcher(mContext); sThis.set(this); onRegisteredServicesCacheChanged(); } public void onRegisteredServicesCacheChanged() { public void onServiceChanged(AuthenticatorDescription desc, boolean removed) { boolean accountDeleted = false; SQLiteDatabase db = mOpenHelper.getWritableDatabase(); Cursor cursor = db.query(TABLE_ACCOUNTS, new String[]{ACCOUNTS_ID, ACCOUNTS_TYPE, ACCOUNTS_NAME}, null, null, null, null, null); ACCOUNTS_TYPE + "=?", new String[]{desc.type}, null, null, null); try { while (cursor.moveToNext()) { final long accountId = cursor.getLong(0); final String accountType = cursor.getString(1); final String accountName = cursor.getString(2); if (mAuthenticatorCache.getServiceInfo(AuthenticatorDescription.newKey(accountType)) == null) { Log.d(TAG, "deleting account " + accountName + " because type " + accountType + " no longer has a registered authenticator"); db.delete(TABLE_ACCOUNTS, ACCOUNTS_ID + "=" + accountId, null); accountDeleted = true; } } } finally { cursor.close(); if (accountDeleted) { Loading core/java/android/accounts/AuthenticatorDescription.java +4 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,10 @@ public class AuthenticatorDescription implements Parcelable { return type.equals(other.type); } public String toString() { return "AuthenticatorDescription {type=" + type + "}"; } /** @inhericDoc */ public void writeToParcel(Parcel dest, int flags) { dest.writeString(type); Loading Loading
camera/libcameraservice/CameraService.cpp +43 −28 Original line number Diff line number Diff line Loading @@ -683,6 +683,8 @@ void CameraService::Client::stopPreview() { LOGD("stopPreview (pid %d)", getCallingPid()); // hold main lock during state transition { Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; Loading @@ -698,14 +700,22 @@ void CameraService::Client::stopPreview() if (mSurface != 0 && !mUseOverlay) { mSurface->unregisterBuffers(); } } // hold preview buffer lock { Mutex::Autolock lock(mPreviewLock); mPreviewBuffer.clear(); } } // stop recording mode void CameraService::Client::stopRecording() { LOGD("stopRecording (pid %d)", getCallingPid()); // hold main lock during state transition { Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) return; Loading @@ -722,9 +732,14 @@ void CameraService::Client::stopRecording() mHardware->stopRecording(); mHardware->disableMsgType(CAMERA_MSG_VIDEO_FRAME); LOGD("stopRecording(), hardware stopped OK"); } // hold preview buffer lock { Mutex::Autolock lock(mPreviewLock); mPreviewBuffer.clear(); } } // release a recording frame void CameraService::Client::releaseRecordingFrame(const sp<IMemory>& mem) Loading Loading @@ -1216,10 +1231,10 @@ void CameraService::Client::copyFrameAndPostCopiedFrame(const sp<ICameraClient>& // provided it's big enough. Don't allocate the memory or // perform the copy if there's no callback. // hold the lock while we grab a reference to the preview buffer // hold the preview lock while we grab a reference to the preview buffer sp<MemoryHeapBase> previewBuffer; { Mutex::Autolock lock(mLock); Mutex::Autolock lock(mPreviewLock); if (mPreviewBuffer == 0) { mPreviewBuffer = new MemoryHeapBase(size, 0, NULL); } else if (size > mPreviewBuffer->virtualSize()) { Loading
camera/libcameraservice/CameraService.h +3 −1 Original line number Diff line number Diff line Loading @@ -181,7 +181,6 @@ private: mutable Condition mReady; sp<CameraService> mCameraService; sp<ISurface> mSurface; sp<MemoryHeapBase> mPreviewBuffer; int mPreviewCallbackFlag; sp<MediaPlayer> mMediaPlayerClick; Loading @@ -197,6 +196,9 @@ private: sp<OverlayRef> mOverlayRef; int mOverlayW; int mOverlayH; mutable Mutex mPreviewLock; sp<MemoryHeapBase> mPreviewBuffer; }; // ---------------------------------------------------------------------------- Loading
core/java/android/accounts/AccountAuthenticatorCache.java +21 −1 Original line number Diff line number Diff line Loading @@ -18,10 +18,16 @@ package android.accounts; import android.content.pm.PackageManager; import android.content.pm.RegisteredServicesCache; import android.content.pm.XmlSerializerAndParser; import android.content.res.TypedArray; import android.content.Context; import android.util.AttributeSet; import android.text.TextUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; /** * A cache of services that export the {@link IAccountAuthenticator} interface. This cache Loading @@ -33,10 +39,12 @@ import android.text.TextUtils; /* package private */ class AccountAuthenticatorCache extends RegisteredServicesCache<AuthenticatorDescription> { private static final String TAG = "Account"; private static final MySerializer sSerializer = new MySerializer(); public AccountAuthenticatorCache(Context context) { super(context, AccountManager.ACTION_AUTHENTICATOR_INTENT, AccountManager.AUTHENTICATOR_META_DATA_NAME, AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME); AccountManager.AUTHENTICATOR_META_DATA_NAME, AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME, sSerializer); } public AuthenticatorDescription parseServiceAttributes(String packageName, AttributeSet attrs) { Loading @@ -62,4 +70,16 @@ import android.text.TextUtils; sa.recycle(); } } private static class MySerializer implements XmlSerializerAndParser<AuthenticatorDescription> { public void writeAsXml(AuthenticatorDescription item, XmlSerializer out) throws IOException { out.attribute(null, "type", item.type); } public AuthenticatorDescription createFromXml(XmlPullParser parser) throws IOException, XmlPullParserException { return AuthenticatorDescription.newKey(parser.getAttributeValue(null, "type")); } } }
core/java/android/accounts/AccountManagerService.java +8 −13 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ import com.android.internal.R; */ public class AccountManagerService extends IAccountManager.Stub implements RegisteredServicesCacheListener { implements RegisteredServicesCacheListener<AuthenticatorDescription> { private static final String GOOGLE_ACCOUNT_TYPE = "com.google"; private static final String NO_BROADCAST_FLAG = "nobroadcast"; Loading Loading @@ -220,35 +220,30 @@ public class AccountManagerService mMessageHandler = new MessageHandler(mMessageThread.getLooper()); mAuthenticatorCache = new AccountAuthenticatorCache(mContext); mAuthenticatorCache.setListener(this); mAuthenticatorCache.setListener(this, null /* Handler */); mBindHelper = new AuthenticatorBindHelper(mContext, mAuthenticatorCache, mMessageHandler, MESSAGE_CONNECTED, MESSAGE_DISCONNECTED); mSimWatcher = new SimWatcher(mContext); sThis.set(this); onRegisteredServicesCacheChanged(); } public void onRegisteredServicesCacheChanged() { public void onServiceChanged(AuthenticatorDescription desc, boolean removed) { boolean accountDeleted = false; SQLiteDatabase db = mOpenHelper.getWritableDatabase(); Cursor cursor = db.query(TABLE_ACCOUNTS, new String[]{ACCOUNTS_ID, ACCOUNTS_TYPE, ACCOUNTS_NAME}, null, null, null, null, null); ACCOUNTS_TYPE + "=?", new String[]{desc.type}, null, null, null); try { while (cursor.moveToNext()) { final long accountId = cursor.getLong(0); final String accountType = cursor.getString(1); final String accountName = cursor.getString(2); if (mAuthenticatorCache.getServiceInfo(AuthenticatorDescription.newKey(accountType)) == null) { Log.d(TAG, "deleting account " + accountName + " because type " + accountType + " no longer has a registered authenticator"); db.delete(TABLE_ACCOUNTS, ACCOUNTS_ID + "=" + accountId, null); accountDeleted = true; } } } finally { cursor.close(); if (accountDeleted) { Loading
core/java/android/accounts/AuthenticatorDescription.java +4 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,10 @@ public class AuthenticatorDescription implements Parcelable { return type.equals(other.type); } public String toString() { return "AuthenticatorDescription {type=" + type + "}"; } /** @inhericDoc */ public void writeToParcel(Parcel dest, int flags) { dest.writeString(type); Loading