Java Code Examples for android.os.Bundle#getBinder()

The following examples show how to use android.os.Bundle#getBinder() . These examples are extracted from open source projects. 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 Project: AndroidWear-OpenWear   File: WatchFaceService.java    License: MIT License 6 votes vote down vote up
private void onSetBinder(Bundle extras) {
    IBinder binder = extras.getBinder("binder");
    if (binder != null) {
        this.mWatchFaceService = IWatchFaceService.Stub.asInterface(binder);
        if (this.mWatchFaceStyle != null) {
            try {
                this.mWatchFaceService.setStyle(this.mWatchFaceStyle);
                this.mWatchFaceStyle = null;
            } catch (RemoteException e) {
                Log.w("WatchFaceService", "Failed to set WatchFaceStyle", e);
            }
        }
    } else {
        Log.w("WatchFaceService", "Binder is null.");
    }
}
 
Example 2
private IBinder getBinder(Bundle extras, String key) {
    IBinder binder = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        binder = extras.getBinder(key);
    }
    return binder;
}
 
Example 3
Source Project: VirtualAPK   File: PluginUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static IBinder getBinder(Bundle bundle, String key) {
    if (bundle == null) {
        return null;
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return bundle.getBinder(key);
    } else {
        return (IBinder) Reflector.QuietReflector.with(bundle)
            .method("getIBinder", String.class).call(key);
    }
}
 
Example 4
public static IBinder getBinder(Bundle bundle, String key) {
	if (Build.VERSION.SDK_INT >= 18) {
		return bundle.getBinder(key);
	} else {
		return mirror.android.os.Bundle.getIBinder.call(bundle, key);
	}
}
 
Example 5
Source Project: Android-ServiceManager   File: BundleCompat.java    License: MIT License 5 votes vote down vote up
public static IBinder getBinder(Bundle bundle, String key) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return bundle.getBinder(key);
    } else {
        return (IBinder) RefIectUtil.invokeMethod(bundle, Bundle.class, "getIBinder", new Class[]{String.class}, new Object[]{key});
    }
}
 
Example 6
public static IBinder getBinder(Bundle bundle, String key) {
    if (Build.VERSION.SDK_INT >= 18) {
        return bundle.getBinder(key);
    } else {
        if(getIBinder != null) {
            try {
                return (IBinder) getIBinder.invoke(bundle, key);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}
 
Example 7
Source Project: android-test   File: SpeakEasyProtocol.java    License: Apache License 2.0 5 votes vote down vote up
/** Gets an IBinder from a bundle safely. */
private static IBinder getBinder(Bundle b, String key) {
  if (null != GET_IBINDER) {
    try {
      return (IBinder) GET_IBINDER.invoke(b, key);
    } catch (InvocationTargetException | IllegalAccessException ex) {
      throw new RuntimeException(ex);
    }
  }
  return b.getBinder(key);
}
 
Example 8
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    if (requestCode == REQUEST_PROVISION_PROFILE) {
        if (resultCode == RESULT_OK) {
            if (isWorkProfileAvailable()) {
                // For pre-Oreo, or post-Oreo on some circumstances,
                // by the time this is received, the whole process
                // should have completed.
                recreate();
                return;
            }
            // The sync part of the setup process is completed
            // Wait for the provisioning to complete
            mStorage.setBoolean(LocalStorageManager.PREF_IS_SETTING_UP, true);

            // However, we still have to wait for DummyActivity in work profile to finish
            mProgressDialog = new ProgressDialog(this);
            mProgressDialog.setMessage(getString(R.string.provision_still_pending));
            mProgressDialog.setCancelable(false);
            mProgressDialog.show();
        } else {
            Toast.makeText(this,
                    getString(R.string.work_profile_provision_failed), Toast.LENGTH_LONG).show();
            finish();
        }
    } else if (requestCode == REQUEST_TRY_START_SERVICE_IN_WORK_PROFILE) {
        if (resultCode == RESULT_OK) {
            // RESULT_OK is from DummyActivity. The work profile is enabled!
            bindWorkService();
        } else {
            // In this case, the user has been presented with a prompt
            // to enable work mode, but we have no means to distinguish
            // "ok" and "cancel", so the only way is to tell the user
            // to start again.
            Toast.makeText(this,
                    getString(R.string.work_mode_disabled), Toast.LENGTH_LONG).show();
            finish();
        }
    } else if (requestCode == REQUEST_START_SERVICE_IN_WORK_PROFILE && resultCode == RESULT_OK) {
        Bundle extra = data.getBundleExtra("extra");
        IBinder binder = extra.getBinder("service");
        mServiceWork = IShelterService.Stub.asInterface(binder);
        startKiller();
        buildView();
    } else if (requestCode == REQUEST_SET_DEVICE_ADMIN) {
        if (resultCode == RESULT_OK) {
            // Device Admin is now set, go ahead to provisioning (or initialization)
            init();
        } else {
            Toast.makeText(this, getString(R.string.device_admin_toast), Toast.LENGTH_LONG).show();
            finish();
        }
    } else if (requestCode == REQUEST_DOCUMENTS_CHOOSE_APK && resultCode == RESULT_OK && data != null) {
        Uri uri = data.getData();
        UriForwardProxy proxy = new UriForwardProxy(getApplicationContext(), uri);

        try {
            mServiceWork.installApk(proxy, new IAppInstallCallback.Stub() {
                @Override
                public void callback(int result) {
                    runOnUiThread(() -> {
                        // The other side will have closed the Fd for us
                        if (result == RESULT_OK)
                            Toast.makeText(MainActivity.this,
                                    R.string.install_app_to_profile_success, Toast.LENGTH_LONG).show();
                    });
                }
            });
        } catch (RemoteException e) {
            // Well, I don't know what to do then
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example 9
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static IBinder getBinerAPI18(Bundle data, String key) {
    return data.getBinder(key);
}