Java Code Examples for android.os.IBinder#transact()

The following examples show how to use android.os.IBinder#transact() . 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 File: DisplayTransformManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Propagates the provided color transformation matrix to the SurfaceFlinger.
 */
private static void applyColorMatrix(float[] m) {
    final IBinder flinger = ServiceManager.getService(SURFACE_FLINGER);
    if (flinger != null) {
        final Parcel data = Parcel.obtain();
        data.writeInterfaceToken("android.ui.ISurfaceComposer");
        if (m != null) {
            data.writeInt(1);
            for (int i = 0; i < 16; i++) {
                data.writeFloat(m[i]);
            }
        } else {
            data.writeInt(0);
        }
        try {
            flinger.transact(SURFACE_FLINGER_TRANSACTION_COLOR_MATRIX, data, null, 0);
        } catch (RemoteException ex) {
            Slog.e(TAG, "Failed to set color transform", ex);
        } finally {
            data.recycle();
        }
    }
}
 
Example 2
Source File: DisplayTransformManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Propagates the provided Daltonization mode to the SurfaceFlinger.
 */
private static void applyDaltonizerMode(int mode) {
    final IBinder flinger = ServiceManager.getService(SURFACE_FLINGER);
    if (flinger != null) {
        final Parcel data = Parcel.obtain();
        data.writeInterfaceToken("android.ui.ISurfaceComposer");
        data.writeInt(mode);
        try {
            flinger.transact(SURFACE_FLINGER_TRANSACTION_DALTONIZER, data, null, 0);
        } catch (RemoteException ex) {
            Slog.e(TAG, "Failed to set Daltonizer mode", ex);
        } finally {
            data.recycle();
        }
    }
}
 
Example 3
Source File: DisplayTransformManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Propagates the provided saturation to the SurfaceFlinger.
 */
private void applySaturation(float saturation) {
    SystemProperties.set(PERSISTENT_PROPERTY_SATURATION, Float.toString(saturation));
    final IBinder flinger = ServiceManager.getService(SURFACE_FLINGER);
    if (flinger != null) {
        final Parcel data = Parcel.obtain();
        data.writeInterfaceToken("android.ui.ISurfaceComposer");
        data.writeFloat(saturation);
        try {
            flinger.transact(SURFACE_FLINGER_TRANSACTION_SATURATION, data, null, 0);
        } catch (RemoteException ex) {
            Log.e(TAG, "Failed to set saturation", ex);
        } finally {
            data.recycle();
        }
    }
}
 
Example 4
Source File: DisplayTransformManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Toggles native mode on/off in SurfaceFlinger.
 */
private void setDisplayColor(int color) {
    SystemProperties.set(PERSISTENT_PROPERTY_DISPLAY_COLOR, Integer.toString(color));
    final IBinder flinger = ServiceManager.getService(SURFACE_FLINGER);
    if (flinger != null) {
        final Parcel data = Parcel.obtain();
        data.writeInterfaceToken("android.ui.ISurfaceComposer");
        data.writeInt(color);
        try {
            flinger.transact(SURFACE_FLINGER_TRANSACTION_DISPLAY_COLOR, data, null, 0);
        } catch (RemoteException ex) {
            Log.e(TAG, "Failed to set display color", ex);
        } finally {
            data.recycle();
        }
    }
}
 
Example 5
Source File: ITelephonyUtil.java    From CacheEmulatorChecker with Apache License 2.0 6 votes vote down vote up
private static String binderGetHardwareInfo(String callingPackage,
                                            IBinder remote,
                                            String DESCRIPTOR,
                                            int tid) throws RemoteException {

    android.os.Parcel _data = android.os.Parcel.obtain();
    android.os.Parcel _reply = android.os.Parcel.obtain();
    String _result;
    try {
        _data.writeInterfaceToken(DESCRIPTOR);
        if (!TextUtils.isEmpty(callingPackage)) {
            _data.writeString(callingPackage);
        }
        remote.transact(tid, _data, _reply, 0);
        _reply.readException();
        _result = _reply.readString();
    } finally {
        _reply.recycle();
        _data.recycle();
    }
    return _result;
}
 
Example 6
Source File: IPhoneSubInfoUtil.java    From CacheEmulatorChecker with Apache License 2.0 6 votes vote down vote up
private static String binderGetHardwareInfo(String callingPackage,
                                            IBinder remote,
                                            String DESCRIPTOR,
                                            int tid) throws RemoteException {

    android.os.Parcel _data = android.os.Parcel.obtain();
    android.os.Parcel _reply = android.os.Parcel.obtain();
    String _result;
    try {
        _data.writeInterfaceToken(DESCRIPTOR);
        if (!TextUtils.isEmpty(callingPackage)) {
            _data.writeString(callingPackage);
        }
        remote.transact(tid, _data, _reply, 0);
        _reply.readException();
        _result = _reply.readString();
    } finally {
        _reply.recycle();
        _data.recycle();
    }
    return _result;
}
 
Example 7
Source File: MethodRouter.java    From Android-ServiceManager with MIT License 6 votes vote down vote up
private static Bundle transact(String descriptor, IBinder remote, Bundle param) throws RemoteException {
    android.os.Parcel _data = android.os.Parcel.obtain();
    android.os.Parcel _reply = android.os.Parcel.obtain();
    Bundle _result;
    try {
        _data.writeInterfaceToken(descriptor);
        if ((param != null)) {
            _data.writeInt(1);
            param.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        remote.transact(ProcessBinder.FIRST_CODE, _data, _reply, 0);
        _reply.readException();
        if ((0 != _reply.readInt())) {
            _result = Bundle.CREATOR.createFromParcel(_reply);
        } else {
            _result = null;
        }
    } finally {
        _reply.recycle();
        _data.recycle();
    }
    return _result;
}
 
Example 8
Source File: OpenUDID_manager.java    From Cangol-appcore with Apache License 2.0 6 votes vote down vote up
@Override
	public void onServiceConnected(ComponentName className, IBinder service) {
//Get the org.OpenUDID from the remote service
try {
	//Send a random number to the service
	android.os.Parcel data = android.os.Parcel.obtain(); 
	data.writeInt(mRandom.nextInt());
	android.os.Parcel reply = android.os.Parcel.obtain(); 
	service.transact(1, android.os.Parcel.obtain(), reply, 0);
	if (data.readInt() == reply.readInt()) //Check if the service returns us this number
	{
		final String _openUDID = reply.readString();
		if (_openUDID != null) { //if valid org.OpenUDID, save it
			if (LOG) Log.d(TAG, "Received " + _openUDID);

			if (mReceivedOpenUDIDs.containsKey(_openUDID)) mReceivedOpenUDIDs.put(_openUDID, mReceivedOpenUDIDs.get(_openUDID) + 1);
			else mReceivedOpenUDIDs.put(_openUDID, 1);
				
		}
	}
} catch (RemoteException e) {if (LOG) Log.e(TAG, "RemoteException: " + e.getMessage());}		    	    			
mContext.unbindService(this);

startService(); //Try the next one
	}