android.os.DeadObjectException Java Examples

The following examples show how to use android.os.DeadObjectException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#update ContentProvider.update} */
public int update(@NonNull Uri url, @Nullable ContentValues values, @Nullable String selection,
        @Nullable String[] selectionArgs) throws RemoteException {
    Preconditions.checkNotNull(url, "url");

    beforeRemote();
    try {
        return mContentProvider.update(mPackageName, url, values, selection, selectionArgs);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #2
Source File: QueueOperation.java    From RxAndroidBle with Apache License 2.0 6 votes vote down vote up
/**
 * A function that returns this operation as an Observable.
 * When the returned observable is subscribed, this operation will be scheduled
 * to be run on the main thread. When appropriate the call to run() will be executed.
 * This operation is expected to call releaseRadio() at appropriate point after the run() was called.
 */
@Override
public final Observable<T> run(final QueueReleaseInterface queueReleaseInterface) {

    return Observable.create(
            new ObservableOnSubscribe<T>() {
                @Override
                public void subscribe(ObservableEmitter<T> emitter) {
                    try {
                        protectedRun(emitter, queueReleaseInterface);
                    } catch (DeadObjectException deadObjectException) {
                        emitter.tryOnError(provideException(deadObjectException));
                        RxBleLog.e(deadObjectException, "QueueOperation terminated with a DeadObjectException");
                    } catch (Throwable throwable) {
                        emitter.tryOnError(throwable);
                        RxBleLog.e(throwable, "QueueOperation terminated with an unexpected exception");
                    }
                }
            }
    );
}
 
Example #3
Source File: MyApplication.java    From TowerCollector with Mozilla Public License 2.0 6 votes vote down vote up
private void initUnhandledExceptionHandler() {
    defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(@NotNull Thread thread, @NotNull Throwable ex) {
            Timber.e(ex, "CRASHED");
            if (ExceptionUtils.getRootCause(ex) instanceof SQLiteDatabaseCorruptException) {
                MeasurementsDatabase.deleteDatabase(getApplication());
            }
            // strange but it happens that app is tested on devices with lower SDK - don't send ACRA reports
            // also ignore errors caused by system failures
            if (Build.VERSION.SDK_INT >= BuildConfig.MIN_SDK_VERSION && !(ExceptionUtils.getRootCause(ex) instanceof DeadObjectException)) {
                defaultHandler.uncaughtException(thread, ex);
            }
        }
    });
}
 
Example #4
Source File: IslandSetup.java    From island with Apache License 2.0 6 votes vote down vote up
private static void destroyProfile(final Activity activity) {
	@SuppressWarnings("UnnecessaryLocalVariable") final Context context = activity;		// MethodShuttle accepts only Context, but not Activity.
	MethodShuttle.runInProfile(activity, () -> {
		final DevicePolicies policies = new DevicePolicies(context);
		policies.execute(DevicePolicyManager::clearCrossProfileIntentFilters);
		policies.getManager().wipeData(0);
	}).whenComplete((result, e) -> {
		if (e != null && ! (e instanceof DeadObjectException)) {	// DeadObjectException is normal, as wipeData() also terminated the calling process.
			showPromptForProfileManualRemoval(activity);
			return;
		}
		ClonedHiddenSystemApps.reset(activity, Users.profile);
		activity.finishAffinity();	// Finish the whole activity stack.
		System.exit(0);		// Force terminate the whole app, to avoid potential inconsistency.
	});
}
 
Example #5
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#call(String, String, Bundle)} */
public @Nullable Bundle call(@NonNull String method, @Nullable String arg,
        @Nullable Bundle extras) throws RemoteException {
    Preconditions.checkNotNull(method, "method");

    beforeRemote();
    try {
        return mContentProvider.call(mPackageName, method, arg, extras);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #6
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#applyBatch ContentProvider.applyBatch} */
public @NonNull ContentProviderResult[] applyBatch(
        @NonNull ArrayList<ContentProviderOperation> operations)
                throws RemoteException, OperationApplicationException {
    Preconditions.checkNotNull(operations, "operations");

    beforeRemote();
    try {
        return mContentProvider.applyBatch(mPackageName, operations);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #7
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile} */
public final @Nullable AssetFileDescriptor openTypedAssetFileDescriptor(@NonNull Uri uri,
        @NonNull String mimeType, @Nullable Bundle opts, @Nullable CancellationSignal signal)
                throws RemoteException, FileNotFoundException {
    Preconditions.checkNotNull(uri, "uri");
    Preconditions.checkNotNull(mimeType, "mimeType");

    beforeRemote();
    try {
        ICancellationSignal remoteSignal = null;
        if (signal != null) {
            signal.throwIfCanceled();
            remoteSignal = mContentProvider.createCancellationSignal();
            signal.setRemote(remoteSignal);
        }
        return mContentProvider.openTypedAssetFile(
                mPackageName, uri, mimeType, opts, remoteSignal);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #8
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * 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.
 */
public @Nullable 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();
    }
}
 
Example #9
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * See {@link ContentProvider#openFile ContentProvider.openFile}.  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#openFileDescriptor
 * ContentResolver.openFileDescriptor} API instead.
 */
public @Nullable ParcelFileDescriptor openFile(@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.openFile(mPackageName, url, mode, remoteSignal, null);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #10
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#delete ContentProvider.delete} */
public int delete(@NonNull Uri url, @Nullable String selection,
        @Nullable String[] selectionArgs) throws RemoteException {
    Preconditions.checkNotNull(url, "url");

    beforeRemote();
    try {
        return mContentProvider.delete(mPackageName, url, selection, selectionArgs);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #11
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#bulkInsert ContentProvider.bulkInsert} */
public int bulkInsert(@NonNull Uri url, @NonNull ContentValues[] initialValues)
        throws RemoteException {
    Preconditions.checkNotNull(url, "url");
    Preconditions.checkNotNull(initialValues, "initialValues");

    beforeRemote();
    try {
        return mContentProvider.bulkInsert(mPackageName, url, initialValues);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #12
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#insert ContentProvider.insert} */
public @Nullable Uri insert(@NonNull Uri url, @Nullable ContentValues initialValues)
        throws RemoteException {
    Preconditions.checkNotNull(url, "url");

    beforeRemote();
    try {
        return mContentProvider.insert(mPackageName, url, initialValues);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #13
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#refresh} */
public boolean refresh(Uri url, @Nullable Bundle args,
        @Nullable CancellationSignal cancellationSignal) throws RemoteException {
    Preconditions.checkNotNull(url, "url");

    beforeRemote();
    try {
        ICancellationSignal remoteCancellationSignal = null;
        if (cancellationSignal != null) {
            cancellationSignal.throwIfCanceled();
            remoteCancellationSignal = mContentProvider.createCancellationSignal();
            cancellationSignal.setRemote(remoteCancellationSignal);
        }
        return mContentProvider.refresh(mPackageName, url, args, remoteCancellationSignal);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #14
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#uncanonicalize} */
public final @Nullable Uri uncanonicalize(@NonNull Uri url) throws RemoteException {
    Preconditions.checkNotNull(url, "url");

    beforeRemote();
    try {
        return mContentProvider.uncanonicalize(mPackageName, url);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #15
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#canonicalize} */
public final @Nullable Uri canonicalize(@NonNull Uri url) throws RemoteException {
    Preconditions.checkNotNull(url, "url");

    beforeRemote();
    try {
        return mContentProvider.canonicalize(mPackageName, url);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #16
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** See {@link ContentProvider#getStreamTypes ContentProvider.getStreamTypes} */
public @Nullable String[] getStreamTypes(@NonNull Uri url, @NonNull String mimeTypeFilter)
        throws RemoteException {
    Preconditions.checkNotNull(url, "url");
    Preconditions.checkNotNull(mimeTypeFilter, "mimeTypeFilter");

    beforeRemote();
    try {
        return mContentProvider.getStreamTypes(url, mimeTypeFilter);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #17
Source File: RuntimeInit.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Report a serious error in the current process.  May or may not cause
 * the process to terminate (depends on system settings).
 *
 * @param tag to record with the error
 * @param t exception describing the error site and conditions
 */
public static void wtf(String tag, Throwable t, boolean system) {
    try {
        if (ActivityManager.getService().handleApplicationWtf(
                mApplicationObject, tag, system,
                new ApplicationErrorReport.ParcelableCrashInfo(t))) {
            // The Activity Manager has already written us off -- now exit.
            Process.killProcess(Process.myPid());
            System.exit(10);
        }
    } catch (Throwable t2) {
        if (t2 instanceof DeadObjectException) {
            // System process is dead; ignore
        } else {
            Slog.e(TAG, "Error reporting WTF", t2);
            Slog.e(TAG, "Original WTF:", t);
        }
    }
}
 
Example #18
Source File: NotificationManagerCompat.java    From letv with Apache License 2.0 5 votes vote down vote up
private void processListenerQueue(ListenerRecord record) {
    if (Log.isLoggable(NotificationManagerCompat.TAG, 3)) {
        Log.d(NotificationManagerCompat.TAG, "Processing component " + record.componentName + ", " + record.taskQueue.size() + " queued tasks");
    }
    if (!record.taskQueue.isEmpty()) {
        if (!ensureServiceBound(record) || record.service == null) {
            scheduleListenerRetry(record);
            return;
        }
        while (true) {
            Task task = (Task) record.taskQueue.peek();
            if (task == null) {
                break;
            }
            try {
                if (Log.isLoggable(NotificationManagerCompat.TAG, 3)) {
                    Log.d(NotificationManagerCompat.TAG, "Sending task " + task);
                }
                task.send(record.service);
                record.taskQueue.remove();
            } catch (DeadObjectException e) {
                if (Log.isLoggable(NotificationManagerCompat.TAG, 3)) {
                    Log.d(NotificationManagerCompat.TAG, "Remote service has died: " + record.componentName);
                }
            } catch (RemoteException e2) {
                Log.w(NotificationManagerCompat.TAG, "RemoteException communicating with " + record.componentName, e2);
            }
        }
        if (!record.taskQueue.isEmpty()) {
            scheduleListenerRetry(record);
        }
    }
}
 
Example #19
Source File: P_AndroidBluetoothManager.java    From SweetBlue with GNU General Public License v3.0 5 votes vote down vote up
@Override public final int getBleState()
    {
        try
        {
            if (m_getLeState_marshmallow == null)
            {
                m_getLeState_marshmallow = BluetoothAdapter.class.getDeclaredMethod("getLeState");
            }
            m_refState = (Integer) m_getLeState_marshmallow.invoke(m_adaptor);
            m_state = m_adaptor.getState();
            // This is to fix an issue on the S7 (and perhaps other phones as well), where the OFF
            // state is never returned from the getLeState method. This is because the BLE_ states represent if LE only mode is on/off. This does NOT
            // relate to the Bluetooth radio being on/off. So, we check if STATE_BLE_ON, and the normal getState() method returns OFF, we
            // will return a state of OFF here.
            if (m_refState == BleStatuses.STATE_BLE_ON && m_state == OFF.getNativeCode())
            {
                return m_state;
            }
            else
            {
                // --- RB  > Not sure why this was setting to off, when the above handles the exception we want to handle. Commenting out for now.
//                m_refState = BleStatuses.STATE_OFF;
            }
            return m_refState;
        } catch (Exception e)
        {
            if (e instanceof DeadObjectException)
            {
                BleManager.UhOhListener.UhOh uhoh = BleManager.UhOhListener.UhOh.DEAD_OBJECT_EXCEPTION;
                m_bleManager.uhOh(uhoh);
            }
            return m_adaptor.getState();
        }
    }
 
Example #20
Source File: InsulinIntegrationApp.java    From HAPP with GNU General Public License v3.0 5 votes vote down vote up
public void sendTest(){
    Message msg = Message.obtain();
    Bundle bundle = new Bundle();
    bundle.putString    (Constants.treatmentService.ACTION, Constants.treatmentService.OUTGOING_TEST_MSG);
    bundle.putLong      (Constants.treatmentService.DATE_REQUESTED, new Date().getTime());
    bundle.putString    (Constants.treatmentService.PUMP, "");
    msg.setData(bundle);

    try {
        pump_driver_Service.send(msg);

    } catch (DeadObjectException d){
        Crashlytics.logException(d);
        d.printStackTrace();
    } catch (RemoteException e) {
        Crashlytics.logException(e);
        e.printStackTrace();
    }
}
 
Example #21
Source File: MultiprocessSharedPreferences.java    From MultiprocessSharedPreferences with Apache License 2.0 5 votes vote down vote up
private boolean isPackageManagerHasDiedException(Throwable e) {
//		1、packageManager.getPackageInfo
//		java.lang.RuntimeException: Package manager has died
//		at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:80)
//		...
//		Caused by: android.os.DeadObjectException
//		at android.os.BinderProxy.transact(Native Method)
//		at android.content.pm.IPackageManager$Stub$Proxy.getPackageInfo(IPackageManager.java:1374)

//		2、contentResolver.query
//		java.lang.RuntimeException: Package manager has died
//		at android.app.ApplicationPackageManager.resolveContentProvider(ApplicationPackageManager.java:636)
//		at android.app.ActivityThread.acquireProvider(ActivityThread.java:4750)
//		at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2234)
//		at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1425)
//		at android.content.ContentResolver.query(ContentResolver.java:445)
//		at android.content.ContentResolver.query(ContentResolver.java:404)
//		at com.qihoo.storager.MultiprocessSharedPreferences.getValue(AppStore:502)
//		...
//		Caused by: android.os.TransactionTooLargeException
//		at android.os.BinderProxy.transact(Native Method)
//		at android.content.pm.IPackageManager$Stub$Proxy.resolveContentProvider(IPackageManager.java:2500)
//		at android.app.ApplicationPackageManager.resolveContentProvider(ApplicationPackageManager.java:634)
		if (e instanceof  RuntimeException
				&& e.getMessage() != null
				&& e.getMessage().contains("Package manager has died")) {
			Throwable cause = getLastCause(e);
			if (cause instanceof DeadObjectException || cause.getClass().getName().equals("android.os.TransactionTooLargeException")) {
				return true;
			}
		}
		return false;
	}
 
Example #22
Source File: SensorbergService.java    From android-sdk with MIT License 5 votes vote down vote up
public void send(BeaconEvent beaconEvent) {
    for (Messenger messenger : storage) {
        try {
            Message message = Message.obtain(null, SensorbergServiceMessage.MSG_PRESENT_ACTION);
            Bundle bundle = new Bundle();
            bundle.putParcelable(SensorbergServiceMessage.MSG_PRESENT_ACTION_BEACONEVENT, beaconEvent);
            message.setData(bundle);
            messenger.send(message);
        } catch (DeadObjectException d) {
            //we need to remove this object!!
        } catch (RemoteException e) {
            logError("something went wrong sending BeaconEvent through Messenger", e);
        }
    }
}
 
Example #23
Source File: P_AndroidBluetoothManager.java    From AsteroidOSSync with GNU General Public License v3.0 5 votes vote down vote up
@Override public final int getBleState()
    {
        try
        {
            if (m_getLeState_marshmallow == null)
            {
                m_getLeState_marshmallow = BluetoothAdapter.class.getDeclaredMethod("getLeState");
            }
            m_refState = (Integer) m_getLeState_marshmallow.invoke(m_adaptor);
            m_state = m_adaptor.getState();
            // This is to fix an issue on the S7 (and perhaps other phones as well), where the OFF
            // state is never returned from the getLeState method. This is because the BLE_ states represent if LE only mode is on/off. This does NOT
            // relate to the Bluetooth radio being on/off. So, we check if STATE_BLE_ON, and the normal getState() method returns OFF, we
            // will return a state of OFF here.
            if (m_refState == BleStatuses.STATE_BLE_ON && m_state == OFF.getNativeCode())
            {
                return m_state;
            }
            else
            {
                // --- RB  > Not sure why this was setting to off, when the above handles the exception we want to handle. Commenting out for now.
//                m_refState = BleStatuses.STATE_OFF;
            }
            return m_refState;
        } catch (Exception e)
        {
            if (e instanceof DeadObjectException)
            {
                BleManager.UhOhListener.UhOh uhoh = BleManager.UhOhListener.UhOh.DEAD_OBJECT_EXCEPTION;
                m_bleManager.uhOh(uhoh);
            }
            return m_adaptor.getState();
        }
    }
 
Example #24
Source File: SdlRouterService.java    From sdl_java_suite with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public int sendMessage(Message message){
	if(this.messenger == null){return SEND_MESSAGE_ERROR_MESSENGER_NULL;}
	if(message == null){return SEND_MESSAGE_ERROR_MESSAGE_NULL;}
	try {
		this.messenger.send(message);
		return SEND_MESSAGE_SUCCESS;
	} catch (RemoteException e) {
		e.printStackTrace();
		if(e instanceof DeadObjectException){
			return SEND_MESSAGE_ERROR_MESSENGER_DEAD_OBJECT;
		}else{
			return SEND_MESSAGE_ERROR_MESSENGER_GENERIC_EXCEPTION;
		}
	}
}
 
Example #25
Source File: RuntimeInit.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void uncaughtException(Thread t, Throwable e) {
    try {
        ensureLogging(t, e);

        // Don't re-enter -- avoid infinite loops if crash-reporting crashes.
        if (mCrashing) return;
        mCrashing = true;

        // Try to end profiling. If a profiler is running at this point, and we kill the
        // process (below), the in-memory buffer will be lost. So try to stop, which will
        // flush the buffer. (This makes method trace profiling useful to debug crashes.)
        if (ActivityThread.currentActivityThread() != null) {
            ActivityThread.currentActivityThread().stopProfiling();
        }

        // Bring up crash dialog, wait for it to be dismissed
        ActivityManager.getService().handleApplicationCrash(
                mApplicationObject, new ApplicationErrorReport.ParcelableCrashInfo(e));
    } catch (Throwable t2) {
        if (t2 instanceof DeadObjectException) {
            // System process is dead; ignore
        } else {
            try {
                Clog_e(TAG, "Error reporting crash", t2);
            } catch (Throwable t3) {
                // Even Clog_e() fails!  Oh well.
            }
        }
    } finally {
        // Try everything to make sure this process goes away.
        Process.killProcess(Process.myPid());
        System.exit(10);
    }
}
 
Example #26
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** See {@link ContentProvider#query ContentProvider.query} */
public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
        Bundle queryArgs, @Nullable CancellationSignal cancellationSignal)
                throws RemoteException {
    Preconditions.checkNotNull(uri, "url");

    beforeRemote();
    try {
        ICancellationSignal remoteCancellationSignal = null;
        if (cancellationSignal != null) {
            cancellationSignal.throwIfCanceled();
            remoteCancellationSignal = mContentProvider.createCancellationSignal();
            cancellationSignal.setRemote(remoteCancellationSignal);
        }
        final Cursor cursor = mContentProvider.query(
                mPackageName, uri, projection, queryArgs, remoteCancellationSignal);
        if (cursor == null) {
            return null;
        }
        return new CursorWrapperInner(cursor);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #27
Source File: ContentProviderClient.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** See {@link ContentProvider#getType ContentProvider.getType} */
public @Nullable String getType(@NonNull Uri url) throws RemoteException {
    Preconditions.checkNotNull(url, "url");

    beforeRemote();
    try {
        return mContentProvider.getType(url);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
 
Example #28
Source File: LocalProxyUtils.java    From container with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generates the Proxy instance for a base object, each IPC call will clean its calling identity.
 * @param interfaceClass interface class
 * @param base base object
 * @param handler retry to get the remote object when server dead.
 * @return proxy object
 */
public static <T> T genProxy(Class<T> interfaceClass, final Object base, final DeadServerHandler handler) {
    //noinspection unchecked
    return (T) Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class[]{ interfaceClass }, new InvocationHandler() {
        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            try {
                return method.invoke(base, args);
            } catch (Throwable e) {
                if (e.getCause() instanceof DeadObjectException) {
                    ServiceManagerNative.clearServerFetcher();
                    if (handler != null) {
                        Object newBase = handler.getNewRemoteInterface();
                        if (newBase != null) {
                            try {
                                return method.invoke(newBase, args);
                            } catch (Throwable retry_e) {
                                throw retry_e.getCause();
                            }
                        }
                        throw e.getCause();
                    }
                }
                throw e.getCause() == null ? e : e.getCause();
            }
        }
    });
}
 
Example #29
Source File: ActivityResponse.java    From letv with Apache License 2.0 5 votes vote down vote up
public void onResult(Bundle result) {
    try {
        this.response.onResult(result);
    } catch (DeadObjectException e) {
        LOG.e(TAG, "[result:" + result + "] on result failed(DeadObjectException)", e);
    } catch (RemoteException e2) {
        LOG.e(TAG, "[result:" + result + "] on result failed(RemoteException)", e2);
    } catch (Throwable e3) {
        LOG.e(TAG, "[result:" + result + "] on result failed(Throwable)", e3);
    }
}
 
Example #30
Source File: ActivityResponse.java    From letv with Apache License 2.0 5 votes vote down vote up
public void onError(int error, String message) {
    try {
        this.response.onError(error, message);
    } catch (DeadObjectException e) {
        LOG.e(TAG, "[error:" + error + "][message:" + message + "] on error failed(DeadObjectException)", e);
    } catch (RemoteException e2) {
        LOG.e(TAG, "[error:" + error + "][message:" + message + "] on error failed(RemoteException)", e2);
    } catch (Throwable e3) {
        LOG.e(TAG, "[error:" + error + "][message:" + message + "] on error failed(Throwable)", e3);
    }
}