android.os.IBinder Java Examples
The following examples show how to use
android.os.IBinder.
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: api-ntrip-java-client Author: OneStopTransport File: NTrip.java License: MIT License | 7 votes |
public void onServiceConnected(ComponentName className, IBinder service) { mService = new Messenger(service); try { //Register client with service Message msg = Message.obtain(null, NTRIPService.MSG_REGISTER_CLIENT); msg.replyTo = mMessenger; mService.send(msg); //Request a status update. msg = Message.obtain(null, NTRIPService.MSG_UPDATE_STATUS, 0, 0); mService.send(msg); //Request full log from service. msg = Message.obtain(null, NTRIPService.MSG_UPDATE_LOG_FULL, 0, 0); mService.send(msg); SetSettings(); NTrip.this.onServiceConnected(); } catch (RemoteException e) { // In this case the service has crashed before we could even do anything with it } }
Example #2
Source Project: android_9.0.0_r45 Author: lulululbj File: TvInputManagerService.java License: Apache License 2.0 | 6 votes |
@Override public void unblockContent( IBinder sessionToken, String unblockedRating, int userId) { ensureParentalControlsPermission(); final int callingUid = Binder.getCallingUid(); final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid, userId, "unblockContent"); final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { try { getSessionLocked(sessionToken, callingUid, resolvedUserId) .unblockContent(unblockedRating); } catch (RemoteException | SessionNotFoundException e) { Slog.e(TAG, "error in unblockContent", e); } } } finally { Binder.restoreCallingIdentity(identity); } }
Example #3
Source Project: moserp Author: thomasletsch File: AndroidDevicePreparingTestRule.java License: Apache License 2.0 | 6 votes |
private void setSystemAnimationsScale(float animationScale) { try { Class<?> windowManagerStubClazz = Class.forName("android.view.IWindowManager$Stub"); Method asInterface = windowManagerStubClazz.getDeclaredMethod("asInterface", IBinder.class); Class<?> serviceManagerClazz = Class.forName("android.os.ServiceManager"); Method getService = serviceManagerClazz.getDeclaredMethod("getService", String.class); Class<?> windowManagerClazz = Class.forName("android.view.IWindowManager"); Method setAnimationScales = windowManagerClazz.getDeclaredMethod("setAnimationScales", float[].class); Method getAnimationScales = windowManagerClazz.getDeclaredMethod("getAnimationScales"); IBinder windowManagerBinder = (IBinder) getService.invoke(null, "window"); Object windowManagerObj = asInterface.invoke(null, windowManagerBinder); float[] currentScales = (float[]) getAnimationScales.invoke(windowManagerObj); for (int i = 0; i < currentScales.length; i++) { currentScales[i] = animationScale; } setAnimationScales.invoke(windowManagerObj, new Object[]{currentScales}); } catch (Exception e) { Log.e("SystemAnimations", "Could not change animation scale to " + animationScale + " :'("); } }
Example #4
Source Project: Musicoco Author: DuanJiaNing File: PlayServiceConnection.java License: Apache License 2.0 | 6 votes |
@Override public void onServiceConnected(ComponentName name, IBinder service) { hasConnected = true; mControl = IPlayControl.Stub.asInterface(service); try { mControl.registerOnPlayStatusChangedListener(mPlayStatusChangedListener); mControl.registerOnSongChangedListener(mSongChangedListener); mControl.registerOnPlayListChangedListener(mPlayListChangedListener); mControl.registerOnDataIsReadyListener(mDataIsReadyListener); } catch (RemoteException e) { e.printStackTrace(); } serviceConnect.onConnected(name, service); }
Example #5
Source Project: kboard Author: adgad File: KboardIME.java License: GNU General Public License v3.0 | 6 votes |
private void switchIME() { //final String LATIN = "com.android.inputmethod.latin/.LatinIME"; // 'this' is an InputMethodService try { InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); final IBinder token = Objects.requireNonNull(this.getWindow().getWindow()).getAttributes().token; //imm.setInputMethod(token, LATIN); imm.switchToNextInputMethod(token, false); } catch (Throwable t) { // java.lang.NoSuchMethodError if API_level<11 mInputMethodManager.showInputMethodPicker(); Log.e(TAG, "cannot set the previous input method:"); t.printStackTrace(); } }
Example #6
Source Project: VideoOS-Android-SDK Author: VideoOS File: VenvyKeyboardMapper.java License: GNU General Public License v3.0 | 6 votes |
public LuaValue hideKeyboard(U target, Varargs varargs) { View view = target.getView(); if (view == null) { return this; } Context context = view.getContext(); if (context instanceof Activity) { View v = ((Activity) context).getCurrentFocus(); if (v != null) { IBinder token = v.getWindowToken(); if (token != null) { InputMethodManager im = (InputMethodManager) context.getSystemService (Context.INPUT_METHOD_SERVICE); im.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS); } } } return this; }
Example #7
Source Project: android_9.0.0_r45 Author: lulululbj File: TvInputManagerService.java License: Apache License 2.0 | 6 votes |
@Override public void stopRecording(IBinder sessionToken, int userId) { final int callingUid = Binder.getCallingUid(); final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid, userId, "stopRecording"); final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { try { getSessionLocked(sessionToken, callingUid, resolvedUserId).stopRecording(); } catch (RemoteException | SessionNotFoundException e) { Slog.e(TAG, "error in stopRecording", e); } } } finally { Binder.restoreCallingIdentity(identity); } }
Example #8
Source Project: springreplugin Author: wangyupeng1-iri File: PluginProviderStub.java License: Apache License 2.0 | 6 votes |
/** * @param context * @return * @throws RemoteException */ public static final IPref getPref(Context context) throws RemoteException { if (sPref == null) { if (IPC.isPersistentProcess()) { // 需要枷锁否? initPref(); } else { IBinder b = PluginProviderStub.proxyFetchHostPref(context); b.linkToDeath(new DeathRecipient() { @Override public void binderDied() { sPref = null; } }, 0); sPref = IPref.Stub.asInterface(b); } } return sPref; }
Example #9
Source Project: android_packages_apps_UnifiedNlp Author: microg File: BackendHelper.java License: Apache License 2.0 | 6 votes |
@Override public void onServiceConnected(ComponentName name, IBinder service) { super.onServiceConnected(name, service); backend = LocationBackend.Stub.asInterface(service); if (backend != null) { try { backend.open(callback); if (updateWaiting) { update(); } } catch (Exception e) { Log.w(TAG, e); unbind(); } } }
Example #10
Source Project: android-chromium Author: kevin-smets File: ChildProcessService.java License: BSD 2-Clause "Simplified" License | 6 votes |
@Override public IBinder onBind(Intent intent) { // We call stopSelf() to request that this service be stopped as soon as the client // unbinds. Otherwise the system may keep it around and available for a reconnect. The // child processes do not currently support reconnect; they must be initialized from // scratch every time. stopSelf(); synchronized (mMainThread) { mCommandLineParams = intent.getStringArrayExtra( ChildProcessConnection.EXTRA_COMMAND_LINE); mLinkerParams = null; if (Linker.isUsed()) mLinkerParams = new LinkerParams(intent); mIsBound = true; mMainThread.notifyAll(); } return mBinder; }
Example #11
Source Project: container Author: codehz File: ActivityStack.java License: GNU General Public License v3.0 | 5 votes |
void onActivityResumed(int userId, IBinder token) { synchronized (mHistory) { optimizeTasksLocked(); ActivityRecord r = findActivityByToken(userId, token); if (r != null) { synchronized (r.task.activities) { r.task.activities.remove(r); r.task.activities.add(r); } } } }
Example #12
Source Project: container Author: codehz File: IApplicationThreadCompat.java License: GNU General Public License v3.0 | 5 votes |
public static void scheduleCreateService(IInterface appThread, IBinder token, ServiceInfo info, int processState) throws RemoteException { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { IApplicationThreadKitkat.scheduleCreateService.call(appThread, token, info, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO.get(), processState); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { IApplicationThreadICSMR1.scheduleCreateService.call(appThread, token, info, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO.get()); } else { IApplicationThread.scheduleCreateService.call(appThread, token, info); } }
Example #13
Source Project: Utils Author: AndroidKnife File: SoftInput.java License: Apache License 2.0 | 5 votes |
/** * Request to hide the soft input window from the context of the window that is currently accepting input. * This should be called as a result of the user doing some actually than fairly explicitly requests to have the input window hidden. * * @param view the current focused view */ public static boolean hideSoftInputFromWindow(View view) { boolean result = false; if (view != null) { Context context = view.getContext(); IBinder windowToken = view.getWindowToken(); InputMethodManager inputMethodManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); result = inputMethodManager.hideSoftInputFromWindow(windowToken, 0); } return result; }
Example #14
Source Project: your-local-weather Author: thuryn File: UpdateWeatherService.java License: GNU General Public License v3.0 | 5 votes |
public void onServiceConnected(ComponentName className, IBinder binderService) { weatherByVoiceService = new Messenger(binderService); weatherByVoiceServiceLock.lock(); try { while (!weatherByvOiceUnsentMessages.isEmpty()) { weatherByVoiceService.send(weatherByvOiceUnsentMessages.poll()); } } catch (RemoteException e) { appendLog(getBaseContext(), TAG, e.getMessage(), e); } finally { weatherByVoiceServiceLock.unlock(); } }
Example #15
Source Project: android-testing-guide Author: ravidsrk File: SampleServiceTest.java License: MIT License | 5 votes |
@Test public void testBoundService() throws TimeoutException { IBinder binder = myServiceRule.bindService( new Intent(InstrumentationRegistry.getTargetContext(), SampleService.class)); SampleService service = ((SampleService.LocalBinder) binder).getService(); // Do work with the service assertNotNull("Bound service is null", service); }
Example #16
Source Project: mobilecloud-15 Author: juleswhite File: Utils.java License: Apache License 2.0 | 5 votes |
/** * This method is used to hide a keyboard after a user has * finished typing the url. */ public static void hideKeyboard(Activity activity, IBinder windowToken) { InputMethodManager mgr = (InputMethodManager) activity.getSystemService (Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(windowToken, 0); }
Example #17
Source Project: HPlayer Author: hezhubo File: DlnaSearch.java License: Apache License 2.0 | 5 votes |
public void onServiceConnected(ComponentName className, IBinder service) { Log.d(TAG, "DLNA-----DlnaAndRemoteSearch---onServiceConnected"); mUpnpService = (AndroidUpnpService) service; mUpnpService.getControlPoint().getRegistry().removeAllRemoteDevices();// 先清除掉之前的,再搜索 mUpnpService.getRegistry().addListener(mDefaultRegistryListener); mUpnpService.getControlPoint().search(); }
Example #18
Source Project: android_9.0.0_r45 Author: lulululbj File: LoadedApk.java License: Apache License 2.0 | 5 votes |
public void connected(ComponentName name, IBinder service, boolean dead) throws RemoteException { LoadedApk.ServiceDispatcher sd = mDispatcher.get(); if (sd != null) { sd.connected(name, service, dead); } }
Example #19
Source Project: android_9.0.0_r45 Author: lulululbj File: TvRemoteProviderProxy.java License: Apache License 2.0 | 5 votes |
@Override public void sendTimestamp(IBinder token, long timestamp) throws RemoteException { Connection connection = mConnectionRef.get(); if (connection != null) { connection.sendTimestamp(token, timestamp); } }
Example #20
Source Project: springreplugin Author: wangyupeng1-iri File: PluginLoader.java License: Apache License 2.0 | 5 votes |
@Override public IModule query(Class<? extends IModule> c) { IBinder b = null; try { b = mPlugin.query(c.getName()); } catch (Throwable e) { if (LOGR) { LogRelease.e(PLUGIN_TAG, "query(" + c + ") exception: " + e.getMessage(), e); } } // TODO: return IModule return null; }
Example #21
Source Project: grblcontroller Author: zeevy File: UsbConnectionActivity.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onServiceConnected(ComponentName className, IBinder service) { grblUsbSerialService = ((GrblUsbSerialService.UsbSerialBinder) service).getService(); mBound = true; grblUsbSerialService.setMessageHandler(grblServiceMessageHandler); grblUsbSerialService.setStatusUpdatePoolInterval(Long.valueOf(sharedPref.getString(getString(R.string.preference_update_pool_interval), String.valueOf(Constants.GRBL_STATUS_UPDATE_INTERVAL)))); }
Example #22
Source Project: Android-Keyboard Author: NlptechProduct File: LatinIME.java License: Apache License 2.0 | 5 votes |
public void showSubtypeSwitchDialog() { // prepare dialog final Dialog dialog = new Dialog( DialogUtils.getPlatformDialogThemeContext(this), R.style.CustomDialogTheme ); SubtypeSwitchDialogView dialogView = (SubtypeSwitchDialogView) getLayoutInflater().inflate(R.layout.subtype_switch, null); dialogView.setListener(this); dialog.setContentView(dialogView); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); // show dialog final IBinder windowToken = KeyboardSwitcher.getInstance().getMainKeyboardView().getWindowToken(); if (windowToken == null) { return; } final Window window = dialog.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); window.setNavigationBarColor(Color.TRANSPARENT); } WindowManager.LayoutParams lp = window.getAttributes(); lp.token = windowToken; lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; mSubtypeSwitchDialog = dialog; dialog.show(); }
Example #23
Source Project: iGap-Android Author: RooyeKhat-Media File: ILicenseResultListener.java License: GNU Affero General Public License v3.0 | 5 votes |
/** * Cast an IBinder object into an ILicenseResultListener interface, * generating a proxy if needed. */ public static com.google.android.vending.licensing.ILicenseResultListener asInterface(android.os.IBinder obj) { if ((obj == null)) { return null; } android.os.IInterface iin = (android.os.IInterface) obj.queryLocalInterface(DESCRIPTOR); if (((iin != null) && (iin instanceof com.google.android.vending.licensing.ILicenseResultListener))) { return ((com.google.android.vending.licensing.ILicenseResultListener) iin); } return new com.google.android.vending.licensing.ILicenseResultListener.Stub.Proxy(obj); }
Example #24
Source Project: brailleback Author: google File: SelfBrailleService.java License: Apache License 2.0 | 5 votes |
@Override public void write(IBinder clientToken, WriteData writeData) { if (clientToken == null) { LogUtils.log(SelfBrailleService.this, Log.ERROR, "null client token to write"); return; } ServiceUtil serviceUtil = new ServiceUtil(mPackageManager); if (!serviceUtil.verifyCaller(Binder.getCallingUid())) { LogUtils.log(SelfBrailleService.this, Log.ERROR, "non-google signed package try to invoke service, rejected."); return; } if (writeData == null) { LogUtils.log(SelfBrailleService.this, Log.ERROR, "null writeData to write"); return; } LogUtils.log(SelfBrailleService.this, Log.VERBOSE, "write %s, %s", writeData.getText(), writeData.getAccessibilityNodeInfo()); try { writeData.validate(); } catch (IllegalStateException ex) { LogUtils.log(SelfBrailleService.this, Log.ERROR, "Invalid write data: %s", ex); return; } NodeState state = new NodeState(); state.mClientToken = clientToken; state.mWriteData = writeData; mHandler.setNodeState(state); }
Example #25
Source Project: Android-Plugin-Framework Author: limpoxe File: PluginInstrumentionWrapper.java License: MIT License | 5 votes |
public ActivityResult execStartActivityAsCaller( Context who, IBinder contextThread, IBinder token, Activity target, Intent intent, int requestCode, Bundle options, int userId) { PluginIntentResolver.resolveActivity(intent); return hackInstrumentation.execStartActivityAsCaller(who, contextThread, token, target, intent, requestCode, options, userId); }
Example #26
Source Project: renrenpay-android Author: wuxiaogu File: MainActivity.java License: Apache License 2.0 | 5 votes |
@Override public void onServiceConnected(ComponentName name, IBinder service) { //实例化Service的内部类myBinder // 通过向下转型得到了MyBinder的实例 socketBinder = (SocketService.SocketBinder) service; //在Activity调用Service类的方法 socketBinder.service_connect_Activity(); socketBinder.addNewOrderInterface(MainActivity.this); }
Example #27
Source Project: GPT Author: baidu File: ActivityManagerNativeWorker.java License: Apache License 2.0 | 5 votes |
public int bindService(IApplicationThread caller, IBinder token, Intent service, String resolvedType, IServiceConnection connection, int flags, int userId) { token = getActivityToken(token); RemapingUtil.remapServiceIntent(mHostContext, service); if (userId == INVALID_USER_ID) { return mTarget.bindService(caller, token, service, resolvedType, connection, flags); } else { return mTarget.bindService(caller, token, service, resolvedType, connection, flags, userId); } }
Example #28
Source Project: android_9.0.0_r45 Author: lulululbj File: VpnService.java License: Apache License 2.0 | 5 votes |
@Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) { if (code == IBinder.LAST_CALL_TRANSACTION) { onRevoke(); return true; } return false; }
Example #29
Source Project: android_9.0.0_r45 Author: lulululbj File: PinnedSliceState.java License: Apache License 2.0 | 5 votes |
public boolean unpin(String pkg, IBinder token) { synchronized (mLock) { token.unlinkToDeath(mDeathRecipient, 0); mListeners.remove(token); } return !hasPinOrListener(); }
Example #30
Source Project: prevent Author: brevent File: PreventRunningUtils.java License: Do What The F*ck You Want To Public License | 4 votes |
public static void onDestroyActivity(IBinder token) { mPreventRunning.onDestroyActivity(forToken(token)); }