private void onResult(IAccountManagerResponse response, Bundle result) { try { response.onResult(result); } catch (RemoteException e) { // if the caller is dead then there is no one to care about remote // exceptions e.printStackTrace(); } }
private Context createPackageContext(String packageName) { try { Context hostContext = VirtualCore.get().getContext(); return hostContext.createPackageContext(packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); VirtualRuntime.crash(new RemoteException()); } throw new RuntimeException(); }
@Override public void onClick(View view) { try { binding.download(TO_DOWNLOAD); } catch (RemoteException e) { Log.e(getClass().getSimpleName(), "Exception requesting download", e); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); } }
@Override public void run() { try { r.process.client.finishActivity(r.token); } catch (RemoteException e) { e.printStackTrace(); } } });
@Override public void renameAccount(int userId, IAccountManagerResponse response, Account accountToRename, String newName) { if (accountToRename == null) throw new IllegalArgumentException("account is null"); Account resultingAccount = renameAccountInternal(userId, accountToRename, newName); Bundle result = new Bundle(); result.putString(AccountManager.KEY_ACCOUNT_NAME, resultingAccount.name); result.putString(AccountManager.KEY_ACCOUNT_TYPE, resultingAccount.type); try { response.onResult(result); } catch (RemoteException e) { Log.w(TAG, e.getMessage()); } }
@Test public void serviceConnected_unbindsAfterRemoteException() throws Exception { binderMock.setStartException(new RemoteException("something bad happened")); connection.onServiceConnected(null, binderMock); assertTrue(connection.wasUnbound()); }
public static boolean isTrackLocal() { try { if (mService != null) { return mService.isTrackLocal(); } } catch (RemoteException e) { e.printStackTrace(); } return false; }
@Override public void onClick(View view) { try { binding.download(TO_DOWNLOAD); } catch (RemoteException e) { Log.e(getClass().getSimpleName(), "Exception requesting download", e); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); } }
@Test public void onStop_unbindsAfterRemoteException() throws Exception { connection.onServiceConnected(null, binderMock); binderMock.verifyStartArguments(jobData, noopCallback); assertFalse(connection.wasUnbound()); binderMock.setStopException(new RemoteException("something bad happened")); connection.onStop(job, true); binderMock.verifyStopArguments(jobData, true); assertTrue(connection.wasUnbound()); verify(contextMock).unbindService(connection); }
private static void linkBinderDied(final IBinder binder) { IBinder.DeathRecipient deathRecipient = new IBinder.DeathRecipient() { @Override public void binderDied() { binder.unlinkToDeath(this, 0); } }; try { binder.linkToDeath(deathRecipient, 0); } catch (RemoteException e) { e.printStackTrace(); } }
@Override public void onClick(View view) { try { binding.download(TO_DOWNLOAD, cb); } catch (RemoteException e) { Log.e(getClass().getSimpleName(), "Exception requesting download", e); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); } }
@TargetApi(18) private void applyChangesToServices(int type, Region region) throws RemoteException { if (mScheduledScanJobsEnabled) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ScanJobScheduler.getInstance().applySettingsToScheduledJob(mContext, this); } return; } if (serviceMessenger == null) { throw new RemoteException("The BeaconManager is not bound to the service. Call beaconManager.bind(BeaconConsumer consumer) and wait for a callback to onBeaconServiceConnect()"); } Message msg = Message.obtain(null, type, 0, 0); if (type == BeaconService.MSG_SET_SCAN_PERIODS) { msg.setData(new StartRMData(this.getScanPeriod(), this.getBetweenScanPeriod(), this.mBackgroundMode).toBundle()); } else if (type == BeaconService.MSG_SYNC_SETTINGS) { msg.setData(new SettingsData().collect(mContext).toBundle()); } else { msg.setData(new StartRMData(region, callbackPackageName(), getScanPeriod(), getBetweenScanPeriod(), mBackgroundMode).toBundle()); } serviceMessenger.send(msg); }
private boolean startServiceByAmsBinder(){ try { if(mRemote == null || mServiceData == null){ Log.e("Daemon", "REMOTE IS NULL or PARCEL IS NULL !!!"); return false; } mRemote.transact(34, mServiceData, null, 0);//START_SERVICE_TRANSACTION = 34 return true; } catch (RemoteException e) { e.printStackTrace(); return false; } }
protected void listVPNs() { try { List<APIVpnProfile> list = mService.getProfiles(); String all="List:"; for(APIVpnProfile vp:list.subList(0, Math.min(5, list.size()))) { all = all + vp.mName + ":" + vp.mUUID + "\n"; } if (list.size() > 5) all +="\n And some profiles...."; if(list.size()> 0) { Button b= mStartVpn; b.setOnClickListener(this); b.setVisibility(View.VISIBLE); b.setText(list.get(0).mName); mStartUUID = list.get(0).mUUID; } mHelloWorld.setText(all); } catch (RemoteException e) { // TODO Auto-generated catch block mHelloWorld.setText(e.getMessage()); } }
private boolean startServiceByAmsBinder(){ try { if(mRemote == null || mServiceData == null){ Log.e("Daemon", "REMOTE IS NULL or PARCEL IS NULL !!!"); return false; } mRemote.transact(34, mServiceData, null, 0);//START_SERVICE_TRANSACTION = 34 return true; } catch (RemoteException e) { e.printStackTrace(); return false; } }
private boolean sendBroadcastByAmsBinder(){ try { if(mRemote == null || mBroadcastData == null){ Log.e("Daemon", "REMOTE IS NULL or PARCEL IS NULL !!!"); return false; } mRemote.transact(14, mBroadcastData, null, 0);//BROADCAST_INTENT_TRANSACTION = 0x00000001 + 13 return true; } catch (RemoteException e) { e.printStackTrace(); return false; } }
public static <T> T crash(RemoteException e) throws RuntimeException { e.printStackTrace(); if (VirtualCore.get().isVAppProcess()) { Process.killProcess(Process.myPid()); System.exit(0); } throw new DeadServerException(e); }
private void deliverNewIntentLocked(ActivityRecord sourceRecord, ActivityRecord targetRecord, Intent intent) { if (targetRecord == null) { return; } String creator = sourceRecord != null ? sourceRecord.component.getPackageName() : "android"; try { targetRecord.process.client.scheduleNewIntent(creator, targetRecord.token, intent); } catch (RemoteException e) { e.printStackTrace(); } catch (NullPointerException npe) { npe.printStackTrace(); } }
public void killAllApps() { try { getService().killAllApps(); } catch (RemoteException e) { e.printStackTrace(); } }
public void registerProcessObserver(IProcessObserver observer) { try { getService().registerProcessObserver(observer); } catch (RemoteException e) { e.printStackTrace(); } }