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;
}
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);
}
}
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);
}
}
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();
}
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);
}
}
}
}
Aggregations