Java Code Examples for android.os.RemoteException

The following examples show how to use android.os.RemoteException. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: letv   Source File: IApkManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
public PermissionGroupInfo getPermissionGroupInfo(String name, int flags) throws RemoteException {
    waitForReadyInner();
    try {
        enforcePluginFileExists();
        if (shouldNotBlockOtherInfo()) {
            for (PluginPackageParser pluginPackageParser : this.mPluginCache.values()) {
                for (PermissionGroupInfo permissionGroupInfo : pluginPackageParser.getPermissionGroups()) {
                    if (TextUtils.equals(permissionGroupInfo.name, name)) {
                        return permissionGroupInfo;
                    }
                }
            }
        }
        List<String> pkgs = this.mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid());
        for (PluginPackageParser pluginPackageParser2 : this.mPluginCache.values()) {
            for (PermissionGroupInfo permissionGroupInfo2 : pluginPackageParser2.getPermissionGroups()) {
                if (TextUtils.equals(permissionGroupInfo2.name, name) && pkgs.contains(permissionGroupInfo2.packageName)) {
                    return permissionGroupInfo2;
                }
            }
        }
    } catch (Exception e) {
        handleException(e);
    }
    return null;
}
 
Example 2
Source Project: RePlugin-GameSdk   Source File: SdkImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void Init(String hostInfo, IInitCallBack initCallBack, ISessionCallBack sessionCallBack, IPayCallBack payCallBack) throws RemoteException {
    Log.e(TAG,"sdkimpl init");
    Activity _ctx = getHostActivity();
    if(_ctx == null){
        return;
    }
    mIInitCallBack = initCallBack;
    mISessionCallBack = sessionCallBack;
    mIPayCallBack = payCallBack;

    Message msg = mH.obtainMessage();
    msg.what = Constant.H_Init;
    msg.obj = hostInfo;
    mH.sendMessage(msg);

}
 
Example 3
Source Project: android_9.0.0_r45   Source File: AuthenticationClient.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean onAcquired(int acquiredInfo, int vendorCode) {
    // If the dialog is showing, the client doesn't need to receive onAcquired messages.
    if (mBundle != null) {
        try {
            if (acquiredInfo != FingerprintManager.FINGERPRINT_ACQUIRED_GOOD) {
                mStatusBarService.onFingerprintHelp(
                        mFingerprintManager.getAcquiredString(acquiredInfo, vendorCode));
            }
            return false; // acquisition continues
        } catch (RemoteException e) {
            Slog.e(TAG, "Remote exception when sending acquired message", e);
            return true; // client failed
        } finally {
            // Good scans will keep the device awake
            if (acquiredInfo == FingerprintManager.FINGERPRINT_ACQUIRED_GOOD) {
                notifyUserActivity();
            }
        }
    } else {
        return super.onAcquired(acquiredInfo, vendorCode);
    }
}
 
Example 4
Source Project: android-easy-checkout   Source File: ConsumePurchaseTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void billingNotSupport() throws InterruptedException, RemoteException, BillingException {
    final CountDownLatch latch = new CountDownLatch(1);

    Bundle stubBundle = new Bundle();
    stubBundle.putInt(ServiceStub.IN_APP_BILLING_SUPPORTED, 1);

    mServiceStub.setServiceForBinding(stubBundle);

    mProcessor.consume(DataConverter.TEST_PRODUCT_ID, new ConsumeItemHandler() {
        @Override
        public void onSuccess() {
            throw new IllegalStateException();
        }

        @Override
        public void onError(BillingException e) {
            assertThat(e.getErrorCode()).isEqualTo(Constants.ERROR_PURCHASES_NOT_SUPPORTED);
            assertThat(e.getMessage()).isEqualTo(Constants.ERROR_MSG_PURCHASES_NOT_SUPPORTED);
            latch.countDown();
        }
    });
    shadowOf(mWorkHandler.getLooper()).getScheduler().advanceToNextPostedRunnable();

    latch.await(15, TimeUnit.SECONDS);
}
 
Example 5
Source Project: kognitivo   Source File: AttributionIdentifiers.java    License: Apache License 2.0 6 votes vote down vote up
public String getAdvertiserId() throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    String id;
    try {
        data.writeInterfaceToken(
                "com.google.android.gms.ads.identifier.internal.IAdvertisingIdService");
        binder.transact(FIRST_TRANSACTION_CODE, data, reply, 0);
        reply.readException();
        id = reply.readString();
    } finally {
        reply.recycle();
        data.recycle();
    }
    return id;
}
 
Example 6
Source Project: android_9.0.0_r45   Source File: LoadedApk.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the array of shared libraries that are listed as
 * used by the given package.
 *
 * @param packageName the name of the package (note: not its
 * file name)
 * @return null-ok; the array of shared libraries, each one
 * a fully-qualified path
 */
private static String[] getLibrariesFor(String packageName) {
    ApplicationInfo ai = null;
    try {
        ai = ActivityThread.getPackageManager().getApplicationInfo(packageName,
                PackageManager.GET_SHARED_LIBRARY_FILES, UserHandle.myUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    if (ai == null) {
        return null;
    }

    return ai.sharedLibraryFiles;
}
 
Example 7
Source Project: android_9.0.0_r45   Source File: TvRemoteProviderProxy.java    License: Apache License 2.0 6 votes vote down vote up
public boolean register() {
    if (DEBUG) Slog.d(TAG, "Connection::register()");
    try {
        mTvRemoteProvider.asBinder().linkToDeath(this, 0);
        mTvRemoteProvider.setRemoteServiceInputSink(mServiceInputProvider);
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                onConnectionReady(Connection.this);
            }
        });
        return true;
    } catch (RemoteException ex) {
        binderDied();
    }
    return false;
}
 
Example 8
Source Project: android_9.0.0_r45   Source File: ContextHubManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Disables a nanoapp at the specified Context Hub.
 *
 * @param hubInfo the hub to disable the nanoapp on
 * @param nanoAppId the app to disable
 *
 * @return the ContextHubTransaction of the request
 *
 * @throws NullPointerException if hubInfo is null
 */
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
@NonNull public ContextHubTransaction<Void> disableNanoApp(
        @NonNull ContextHubInfo hubInfo, long nanoAppId) {
    Preconditions.checkNotNull(hubInfo, "ContextHubInfo cannot be null");

    ContextHubTransaction<Void> transaction =
            new ContextHubTransaction<>(ContextHubTransaction.TYPE_DISABLE_NANOAPP);
    IContextHubTransactionCallback callback = createTransactionCallback(transaction);

    try {
        mService.disableNanoApp(hubInfo.getId(), callback, nanoAppId);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    return transaction;
}
 
Example 9
Source Project: Running   Source File: WalkingActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleMessage(Message msg) {
    switch (msg.what) {

        case Constant.Config.MSG_FROM_SERVER:
            step = Long.valueOf(String.valueOf(msg.getData().get(Constant.Config.stepNum))) - lastStep;
            stepCount.setText(String.valueOf(step));
            calories.setText(String.valueOf(stepToKcal(step)));
            time.setText(String.valueOf(this.timemm));
            delayHandler.sendEmptyMessageDelayed(Constant.Config.REQUEST_SERVER, TIME_INTERVAL);
            break;
        case Constant.Config.REQUEST_SERVER:
            try {
                Message msg1 = Message.obtain(null, Constant.Config.MSG_FROM_CLIENT);
                msg1.replyTo = mGetReplyMessenger;
                messenger.send(msg1);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            break;
        case TIMECOM:
            runnable.run();
            break;
    }
    return false;
}
 
Example 10
@Override
public void onClassifyText(
        TextClassificationSessionId sessionId,
        TextClassification.Request request, ITextClassificationCallback callback)
        throws RemoteException {
    Preconditions.checkNotNull(request);
    Preconditions.checkNotNull(callback);

    synchronized (mLock) {
        UserState userState = getCallingUserStateLocked();
        if (!userState.bindLocked()) {
            callback.onFailure();
        } else if (userState.isBoundLocked()) {
            userState.mService.onClassifyText(sessionId, request, callback);
        } else {
            userState.mPendingRequests.add(new PendingRequest(
                    () -> onClassifyText(sessionId, request, callback),
                    callback::onFailure, callback.asBinder(), this, userState));
        }
    }
}
 
Example 11
Source Project: brailleback   Source File: LabelProviderClient.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets a summary of label info for each package from the label database.
 * <p>
 * Don't run this method on the UI thread. Use {@link android.os.AsyncTask}.
 *
 * @return An unmodifiable list of {@link PackageLabelInfo} objects, or an
 *         empty map if the query returns no results, or {@code null} if the
 *         query fails.
 */
public List<PackageLabelInfo> getPackageSummary(String locale) {
    LogUtils.log(this, Log.DEBUG, "Querying package summary.");

    if (!checkClient()) {
        return null;
    }

    final String[] whereArgs = { locale };

    Cursor cursor = null;
    try {
        cursor = mClient.query(mPackageSummaryContentUri, null /* projection */,
                PACKAGE_SUMMARY_QUERY_WHERE, whereArgs, null /* sortOrder */);

        return getPackageSummaryFromCursor(cursor);
    } catch (RemoteException e) {
        LogUtils.log(this, Log.ERROR, e.toString());
        return null;
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
Example 12
Source Project: android_9.0.0_r45   Source File: LauncherApps.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns {@link ApplicationInfo} about an application installed for a specific user profile.
 *
 * @param packageName The package name of the application
 * @param flags Additional option flags {@link PackageManager#getApplicationInfo}
 * @param user The UserHandle of the profile.
 *
 * @return {@link ApplicationInfo} containing information about the package. Returns
 *         {@code null} if the package isn't installed for the given profile, or the profile
 *         isn't enabled.
 */
public ApplicationInfo getApplicationInfo(@NonNull String packageName,
        @ApplicationInfoFlags int flags, @NonNull UserHandle user)
        throws PackageManager.NameNotFoundException {
    Preconditions.checkNotNull(packageName, "packageName");
    Preconditions.checkNotNull(user, "user");
    logErrorForInvalidProfileAccess(user);
    try {
        final ApplicationInfo ai = mService
                .getApplicationInfo(mContext.getPackageName(), packageName, flags, user);
        if (ai == null) {
            throw new NameNotFoundException("Package " + packageName + " not found for user "
                    + user.getIdentifier());
        }
        return ai;
    } catch (RemoteException re) {
        throw re.rethrowFromSystemServer();
    }
}
 
Example 13
Source Project: android_9.0.0_r45   Source File: BluetoothGatt.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Discovers services offered by a remote device as well as their
 * characteristics and descriptors.
 *
 * <p>This is an asynchronous operation. Once service discovery is completed,
 * the {@link BluetoothGattCallback#onServicesDiscovered} callback is
 * triggered. If the discovery was successful, the remote services can be
 * retrieved using the {@link #getServices} function.
 *
 * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
 *
 * @return true, if the remote service discovery has been started
 */
public boolean discoverServices() {
    if (DBG) Log.d(TAG, "discoverServices() - device: " + mDevice.getAddress());
    if (mService == null || mClientIf == 0) return false;

    mServices.clear();

    try {
        mService.discoverServices(mClientIf, mDevice.getAddress());
    } catch (RemoteException e) {
        Log.e(TAG, "", e);
        return false;
    }

    return true;
}
 
Example 14
/** @hide */
@Override
@SuppressWarnings("unchecked")
public List<PackageInfo> getInstalledPackagesAsUser(int flags, int userId) {
    try {
        ParceledListSlice<PackageInfo> parceledList =
                mPM.getInstalledPackages(flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 15
int runTask(PrintWriter pw) throws RemoteException {
    String op = getNextArgRequired();
    if (op.equals("lock")) {
        return runTaskLock(pw);
    } else if (op.equals("resizeable")) {
        return runTaskResizeable(pw);
    } else if (op.equals("resize")) {
        return runTaskResize(pw);
    } else if (op.equals("focus")) {
        return runTaskFocus(pw);
    } else {
        getErrPrintWriter().println("Error: unknown command '" + op + "'");
        return -1;
    }
}
 
Example 16
Source Project: odyssey   Source File: FilesFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Call the PBS to enqueue all music in the current folder and his children.
 */
private void enqueueCurrentFolderAndSubFolders() {

    try {
        ((GenericActivity) getActivity()).getPlaybackService().enqueueDirectoryAndSubDirectories(mCurrentDirectory.getPath(), mSearchString);
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
 
Example 17
Source Project: DetectMagiskHide   Source File: DetectMagisk.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detect_magisk);

    Button btnMagisk = findViewById(R.id.button);
    btnMagisk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()){
                case R.id.button:
                    if(bServiceBound){
                        boolean bIsMagisk = false;
                        try {
                            bIsMagisk = serviceBinder.isMagiskPresent();
                            if(bIsMagisk)
                                Toast.makeText(getApplicationContext(),"Magisk Found", Toast.LENGTH_LONG).show();
                            else
                                Toast.makeText(getApplicationContext(), "Magisk Not Found", Toast.LENGTH_LONG).show();

                            //getApplicationContext().unbindService(mIsolatedServiceConnection);
                        } catch (RemoteException e) {
                            e.printStackTrace();
                        }
                    }else{
                        Toast.makeText(getApplicationContext(), "Isolated Service not bound", Toast.LENGTH_SHORT).show();
                    }

            }
        }
    });
}
 
Example 18
@Override
public void verifyIntentFilter(int id, int verificationCode, List<String> outFailedDomains) {
    try {
        mPM.verifyIntentFilter(id, verificationCode, outFailedDomains);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example 19
Source Project: external-nfc-api   Source File: Acr1252UReader.java    License: Apache License 2.0 5 votes vote down vote up
public boolean setDefaultLEDAndBuzzerBehaviour(AcrDefaultLEDAndBuzzerBehaviour ... types) {
	byte[] response;
	try {
		int operation = serializeBehaviour(types);
		
		response = readerControl.setDefaultLEDAndBuzzerBehaviour(operation);
	} catch (RemoteException e) {
		throw new AcrReaderException(e);
	}
	
	return readBoolean(response);
}
 
Example 20
Source Project: letv   Source File: ScanningMediaService.java    License: Apache License 2.0 5 votes vote down vote up
private void sendData(int cmd) {
    if (this.messenger != null) {
        Message msg = Message.obtain();
        msg.what = cmd;
        try {
            this.messenger.send(msg);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
 
Example 21
/** @hide */
@Override
public boolean isSignedBy(String packageName, KeySet ks) {
    Preconditions.checkNotNull(packageName);
    Preconditions.checkNotNull(ks);
    try {
        return mPM.isPackageSignedByKeySet(packageName, ks);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 22
Source Project: brailleback   Source File: DisplayService.java    License: Apache License 2.0 5 votes vote down vote up
private void broadcastInputEvent(BrailleInputEvent event) {
    int i = mClients.beginBroadcast();
    try {
        while (i-- > 0) {
            try {
                mClients.getBroadcastItem(i).onInput(event);
            } catch (RemoteException ex) {
                // Nothing to do, the callback list will remove the
                // callback later.
            }
        }
    } finally {
        mClients.finishBroadcast();
    }
}
 
Example 23
@Override
public void freeStorageAndNotify(String volumeUuid, long idealStorageSize,
        IPackageDataObserver observer) {
    try {
        mPM.freeStorageAndNotify(volumeUuid, idealStorageSize, 0, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 24
private void installCommon(Uri packageURI,
        PackageInstallObserver observer, int flags, String installerPackageName,
        int userId) {
    if (!"file".equals(packageURI.getScheme())) {
        throw new UnsupportedOperationException("Only file:// URIs are supported");
    }

    final String originPath = packageURI.getPath();
    try {
        mPM.installPackageAsUser(originPath, observer.getBinder(), flags, installerPackageName,
                userId);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 25
@Override
@SuppressWarnings("unchecked")
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        ParceledListSlice<PermissionGroupInfo> parceledList =
                mPM.getAllPermissionGroups(flags);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 26
Source Project: odyssey   Source File: GenericActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
public IOdysseyPlaybackService getPlaybackService() throws RemoteException {
    if (mServiceConnection != null) {
        return mServiceConnection.getPBS();
    } else {
        throw new RemoteException();
    }
}
 
Example 27
Source Project: PUMA   Source File: MyInteractionController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This method simply presses the power button if the screen is ON else
 * it does nothing if the screen is already OFF.
 * @return true if the device was awake else false
 * @throws RemoteException
 */
public boolean sleepDevice() throws RemoteException {
	if (isScreenOn()) {
		this.sendKey(KeyEvent.KEYCODE_POWER, 0);
		return true;
	}
	return false;
}
 
Example 28
/**
 * Initialize a client record with the dictionary content provider.
 *
 * This merely acquires the content provider and calls
 * #reinitializeClientRecordInDictionaryContentProvider.
 *
 * @param context the context for resources and providers.
 * @param clientId the client ID to use.
 */
public static void initializeClientRecordHelper(final Context context, final String clientId) {
    try {
        final ContentProviderClient client = context.getContentResolver().
                acquireContentProviderClient(getProviderUriBuilder(context, "").build());
        if (null == client) return;
        reinitializeClientRecordInDictionaryContentProvider(context, client, clientId);
    } catch (RemoteException e) {
        Log.e(TAG, "Cannot contact the dictionary content provider", e);
    }
}
 
Example 29
Source Project: AndroidComponentPlugin   Source File: ContextImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void sendBroadcastMultiplePermissions(Intent intent, String[] receiverPermissions) {
    warnIfCallingFromSystemProcess();
    String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
    try {
        intent.prepareToLeaveProcess(this);
        ActivityManagerNative.getDefault().broadcastIntent(
                mMainThread.getApplicationThread(), intent, resolvedType, null,
                Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
                null, false, false, getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 30
Source Project: android_9.0.0_r45   Source File: StatusBarManagerService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void showAssistDisclosure() {
    if (mBar != null) {
        try {
            mBar.showAssistDisclosure();
        } catch (RemoteException e) {
        }
    }
}