use of android.os.DeadObjectException in project android_frameworks_base by AOSPA.
the class ContentProviderClient method openAssetFile.
/**
* See {@link ContentProvider#openAssetFile ContentProvider.openAssetFile}.
* Note that this <em>does not</em>
* take care of non-content: URIs such as file:. It is strongly recommended
* you use the {@link ContentResolver#openAssetFileDescriptor
* ContentResolver.openAssetFileDescriptor} API instead.
*/
@Nullable
public AssetFileDescriptor openAssetFile(@NonNull Uri url, @NonNull String mode, @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
Preconditions.checkNotNull(url, "url");
Preconditions.checkNotNull(mode, "mode");
beforeRemote();
try {
ICancellationSignal remoteSignal = null;
if (signal != null) {
signal.throwIfCanceled();
remoteSignal = mContentProvider.createCancellationSignal();
signal.setRemote(remoteSignal);
}
return mContentProvider.openAssetFile(mPackageName, url, mode, remoteSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
use of android.os.DeadObjectException in project android_frameworks_base by AOSPA.
the class MediaSessionRecord method pushNowPlayingEntries.
private void pushNowPlayingEntries() {
synchronized (mLock) {
if (mDestroyed) {
return;
}
for (int i = mControllerCallbacks.size() - 1; i >= 0; i--) {
ISessionControllerCallback cb = mControllerCallbacks.get(i);
try {
Log.d(TAG, "pushNowPlayingEntries");
cb.onUpdateNowPlayingEntries(mNowPlayingList);
} catch (DeadObjectException e) {
Log.w(TAG, "Removing dead callback in pushNowPlayingEntries. ", e);
mControllerCallbacks.remove(i);
} catch (RemoteException e) {
Log.w(TAG, "unexpected exception in pushNowPlayingEntries. ", e);
}
}
}
}
use of android.os.DeadObjectException in project android_frameworks_base by ResurrectionRemix.
the class MediaSessionRecord method pushPlayItemResponse.
private void pushPlayItemResponse() {
synchronized (mLock) {
if (mDestroyed) {
return;
}
for (int i = mControllerCallbacks.size() - 1; i >= 0; i--) {
ISessionControllerCallback cb = mControllerCallbacks.get(i);
try {
Log.d(TAG, "pushPlayItemResponse");
cb.onPlayItemResponse(mPlayItemStatus);
} catch (DeadObjectException e) {
Log.w(TAG, "Removing dead callback in pushPlayItemResponse. ", e);
mControllerCallbacks.remove(i);
} catch (RemoteException e) {
Log.w(TAG, "unexpected exception in pushPlayItemResponse. ", e);
}
}
}
}
use of android.os.DeadObjectException in project android_frameworks_base by ResurrectionRemix.
the class MediaSessionRecord method pushNowPlayingContentChange.
private void pushNowPlayingContentChange() {
synchronized (mLock) {
if (mDestroyed) {
return;
}
for (int i = mControllerCallbacks.size() - 1; i >= 0; i--) {
ISessionControllerCallback cb = mControllerCallbacks.get(i);
try {
Log.d(TAG, "pushNowPlayingContentChange");
cb.onUpdateNowPlayingContentChange();
} catch (DeadObjectException e) {
Log.w(TAG, "Removing dead callback in pushNowPlayingContentChange. ", e);
mControllerCallbacks.remove(i);
} catch (RemoteException e) {
Log.w(TAG, "unexpected exception in pushNowPlayingContentChange. ", e);
}
}
}
}
use of android.os.DeadObjectException in project android_frameworks_base by ResurrectionRemix.
the class ContentResolver method query.
/**
* Query the given URI, returning a {@link Cursor} over the result set
* with optional support for cancellation.
* <p>
* For best performance, the caller should follow these guidelines:
* <ul>
* <li>Provide an explicit projection, to prevent
* reading data from storage that aren't going to be used.</li>
* <li>Use question mark parameter markers such as 'phone=?' instead of
* explicit values in the {@code selection} parameter, so that queries
* that differ only by those values will be recognized as the same
* for caching purposes.</li>
* </ul>
* </p>
*
* @param uri The URI, using the content:// scheme, for the content to
* retrieve.
* @param projection A list of which columns to return. Passing null will
* return all columns, which is inefficient.
* @param selection A filter declaring which rows to return, formatted as an
* SQL WHERE clause (excluding the WHERE itself). Passing null will
* return all rows for the given URI.
* @param selectionArgs You may include ?s in selection, which will be
* replaced by the values from selectionArgs, in the order that they
* appear in the selection. The values will be bound as Strings.
* @param sortOrder How to order the rows, formatted as an SQL ORDER BY
* clause (excluding the ORDER BY itself). Passing null will use the
* default sort order, which may be unordered.
* @param cancellationSignal A signal to cancel the operation in progress, or null if none.
* If the operation is canceled, then {@link OperationCanceledException} will be thrown
* when the query is executed.
* @return A Cursor object, which is positioned before the first entry, or null
* @see Cursor
*/
@Nullable
public final Cursor query(@RequiresPermission.Read @NonNull final Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder, @Nullable CancellationSignal cancellationSignal) {
android.util.SeempLog.record_uri(13, uri);
Preconditions.checkNotNull(uri, "uri");
IContentProvider unstableProvider = acquireUnstableProvider(uri);
if (unstableProvider == null) {
return null;
}
IContentProvider stableProvider = null;
Cursor qCursor = null;
try {
long startTime = SystemClock.uptimeMillis();
ICancellationSignal remoteCancellationSignal = null;
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
remoteCancellationSignal = unstableProvider.createCancellationSignal();
cancellationSignal.setRemote(remoteCancellationSignal);
}
try {
qCursor = unstableProvider.query(mPackageName, uri, projection, selection, selectionArgs, sortOrder, remoteCancellationSignal);
} catch (DeadObjectException e) {
// The remote process has died... but we only hold an unstable
// reference though, so we might recover!!! Let's try!!!!
// This is exciting!!1!!1!!!!1
unstableProviderDied(unstableProvider);
stableProvider = acquireProvider(uri);
if (stableProvider == null) {
return null;
}
qCursor = stableProvider.query(mPackageName, uri, projection, selection, selectionArgs, sortOrder, remoteCancellationSignal);
}
if (qCursor == null) {
return null;
}
// Force query execution. Might fail and throw a runtime exception here.
qCursor.getCount();
long durationMillis = SystemClock.uptimeMillis() - startTime;
maybeLogQueryToEventLog(durationMillis, uri, projection, selection, sortOrder);
// Wrap the cursor object into CursorWrapperInner object.
final IContentProvider provider = (stableProvider != null) ? stableProvider : acquireProvider(uri);
final CursorWrapperInner wrapper = new CursorWrapperInner(qCursor, provider);
stableProvider = null;
qCursor = null;
return wrapper;
} catch (RemoteException e) {
// Manager will kill this process shortly anyway.
return null;
} finally {
if (qCursor != null) {
qCursor.close();
}
if (cancellationSignal != null) {
cancellationSignal.setRemote(null);
}
if (unstableProvider != null) {
releaseUnstableProvider(unstableProvider);
}
if (stableProvider != null) {
releaseProvider(stableProvider);
}
}
}
Aggregations