Search in sources :

Example 91 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class RemoteListenerHelper method addListener.

public boolean addListener(@NonNull TListener listener) {
    Preconditions.checkNotNull(listener, "Attempted to register a 'null' listener.");
    IBinder binder = listener.asBinder();
    LinkedListener deathListener = new LinkedListener(listener);
    synchronized (mListenerMap) {
        if (mListenerMap.containsKey(binder)) {
            // listener already added
            return true;
        }
        try {
            binder.linkToDeath(deathListener, 0);
        } catch (RemoteException e) {
            // if the remote process registering the listener is already death, just swallow the
            // exception and return
            Log.v(mTag, "Remote listener already died.", e);
            return false;
        }
        mListenerMap.put(binder, deathListener);
        // update statuses we already know about, starting from the ones that will never change
        int result;
        if (!isAvailableInPlatform()) {
            result = RESULT_NOT_AVAILABLE;
        } else if (mHasIsSupported && !mIsSupported) {
            result = RESULT_NOT_SUPPORTED;
        } else if (!isGpsEnabled()) {
            result = RESULT_GPS_LOCATION_DISABLED;
        } else if (!tryRegister()) {
            // only attempt to register if GPS is enabled, otherwise we will register once GPS
            // becomes available
            result = RESULT_INTERNAL_ERROR;
        } else if (mHasIsSupported && mIsSupported) {
            result = RESULT_SUCCESS;
        } else {
            // asynchronously in the future
            return true;
        }
        post(listener, getHandlerOperation(result));
    }
    return true;
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 92 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class MediaRouterService method registerClientLocked.

private void registerClientLocked(IMediaRouterClient client, int pid, String packageName, int userId, boolean trusted) {
    final IBinder binder = client.asBinder();
    ClientRecord clientRecord = mAllClientRecords.get(binder);
    if (clientRecord == null) {
        boolean newUser = false;
        UserRecord userRecord = mUserRecords.get(userId);
        if (userRecord == null) {
            userRecord = new UserRecord(userId);
            newUser = true;
        }
        clientRecord = new ClientRecord(userRecord, client, pid, packageName, trusted);
        try {
            binder.linkToDeath(clientRecord, 0);
        } catch (RemoteException ex) {
            throw new RuntimeException("Media router client died prematurely.", ex);
        }
        if (newUser) {
            mUserRecords.put(userId, userRecord);
            initializeUserLocked(userRecord);
        }
        userRecord.mClientRecords.add(clientRecord);
        mAllClientRecords.put(binder, clientRecord);
        initializeClientLocked(clientRecord);
    }
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 93 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class MediaProjectionManagerService method linkDeathRecipientLocked.

private void linkDeathRecipientLocked(IMediaProjectionWatcherCallback callback, IBinder.DeathRecipient deathRecipient) {
    try {
        final IBinder token = callback.asBinder();
        token.linkToDeath(deathRecipient, 0);
        mDeathEaters.put(token, deathRecipient);
    } catch (RemoteException e) {
        Slog.e(TAG, "Unable to link to death for media projection monitoring callback", e);
    }
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 94 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class LockdownVpnTracker method initLocked.

private void initLocked() {
    Slog.d(TAG, "initLocked()");
    mVpn.setEnableTeardown(false);
    final IntentFilter resetFilter = new IntentFilter(ACTION_LOCKDOWN_RESET);
    mContext.registerReceiver(mResetReceiver, resetFilter, CONNECTIVITY_INTERNAL, null);
    try {
        // TODO: support non-standard port numbers
        mNetService.setFirewallEgressDestRule(mProfile.server, 500, true);
        mNetService.setFirewallEgressDestRule(mProfile.server, 4500, true);
        mNetService.setFirewallEgressDestRule(mProfile.server, 1701, true);
    } catch (RemoteException e) {
        throw new RuntimeException("Problem setting firewall rules", e);
    }
    handleStateChangedLocked();
}
Also used : IntentFilter(android.content.IntentFilter) RemoteException(android.os.RemoteException)

Example 95 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class GnssLocationProvider method updateClientUids.

private void updateClientUids(WorkSource source) {
    // Update work source.
    WorkSource[] changes = mClientSource.setReturningDiffs(source);
    if (changes == null) {
        return;
    }
    WorkSource newWork = changes[0];
    WorkSource goneWork = changes[1];
    // Update sources that were not previously tracked.
    if (newWork != null) {
        int lastuid = -1;
        for (int i = 0; i < newWork.size(); i++) {
            try {
                int uid = newWork.get(i);
                mAppOpsService.startOperation(AppOpsManager.getToken(mAppOpsService), AppOpsManager.OP_GPS, uid, newWork.getName(i));
                if (uid != lastuid) {
                    lastuid = uid;
                    mBatteryStats.noteStartGps(uid);
                }
            } catch (RemoteException e) {
                Log.w(TAG, "RemoteException", e);
            }
        }
    }
    // Update sources that are no longer tracked.
    if (goneWork != null) {
        int lastuid = -1;
        for (int i = 0; i < goneWork.size(); i++) {
            try {
                int uid = goneWork.get(i);
                mAppOpsService.finishOperation(AppOpsManager.getToken(mAppOpsService), AppOpsManager.OP_GPS, uid, goneWork.getName(i));
                if (uid != lastuid) {
                    lastuid = uid;
                    mBatteryStats.noteStopGps(uid);
                }
            } catch (RemoteException e) {
                Log.w(TAG, "RemoteException", e);
            }
        }
    }
}
Also used : WorkSource(android.os.WorkSource) RemoteException(android.os.RemoteException)

Aggregations

RemoteException (android.os.RemoteException)4527 Intent (android.content.Intent)595 IBinder (android.os.IBinder)480 Bundle (android.os.Bundle)461 Point (android.graphics.Point)423 IOException (java.io.IOException)381 PendingIntent (android.app.PendingIntent)274 ComponentName (android.content.ComponentName)265 ArrayList (java.util.ArrayList)248 ApplicationInfo (android.content.pm.ApplicationInfo)190 IPackageManager (android.content.pm.IPackageManager)190 Message (android.os.Message)184 Uri (android.net.Uri)157 UserHandle (android.os.UserHandle)154 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)151 Cursor (android.database.Cursor)150 Configuration (android.content.res.Configuration)133 UserInfo (android.content.pm.UserInfo)129 AndroidRuntimeException (android.util.AndroidRuntimeException)128 ParcelFileDescriptor (android.os.ParcelFileDescriptor)126