Search in sources :

Example 11 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class BatteryService method logBatteryStatsLocked.

private void logBatteryStatsLocked() {
    IBinder batteryInfoService = ServiceManager.getService(BATTERY_STATS_SERVICE_NAME);
    if (batteryInfoService == null)
        return;
    DropBoxManager db = (DropBoxManager) mContext.getSystemService(Context.DROPBOX_SERVICE);
    if (db == null || !db.isTagEnabled("BATTERY_DISCHARGE_INFO"))
        return;
    File dumpFile = null;
    FileOutputStream dumpStream = null;
    try {
        // dump the service to a file
        dumpFile = new File(DUMPSYS_DATA_PATH + BATTERY_STATS_SERVICE_NAME + ".dump");
        dumpStream = new FileOutputStream(dumpFile);
        batteryInfoService.dump(dumpStream.getFD(), DUMPSYS_ARGS);
        FileUtils.sync(dumpStream);
        // add dump file to drop box
        db.addFile("BATTERY_DISCHARGE_INFO", dumpFile, DropBoxManager.IS_TEXT);
    } catch (RemoteException e) {
        Slog.e(TAG, "failed to dump battery service", e);
    } catch (IOException e) {
        Slog.e(TAG, "failed to write dumpsys file", e);
    } finally {
        // make sure we clean up
        if (dumpStream != null) {
            try {
                dumpStream.close();
            } catch (IOException e) {
                Slog.e(TAG, "failed to close dumpsys output stream");
            }
        }
        if (dumpFile != null && !dumpFile.delete()) {
            Slog.e(TAG, "failed to delete temporary dumpsys file: " + dumpFile.getAbsolutePath());
        }
    }
}
Also used : DropBoxManager(android.os.DropBoxManager) IBinder(android.os.IBinder) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) RemoteException(android.os.RemoteException) File(java.io.File)

Example 12 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class MountService method removeObbStateLocked.

private void removeObbStateLocked(ObbState obbState) {
    final IBinder binder = obbState.getBinder();
    final List<ObbState> obbStates = mObbMounts.get(binder);
    if (obbStates != null) {
        if (obbStates.remove(obbState)) {
            obbState.unlink();
        }
        if (obbStates.isEmpty()) {
            mObbMounts.remove(binder);
        }
    }
    mObbPathToStateMap.remove(obbState.rawPath);
}
Also used : IBinder(android.os.IBinder)

Example 13 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class StatusBarManagerService method addNotification.

// ================================================================================
// Callbacks for NotificationManagerService.
// ================================================================================
public IBinder addNotification(StatusBarNotification notification) {
    synchronized (mNotifications) {
        IBinder key = new Binder();
        mNotifications.put(key, notification);
        if (mBar != null) {
            try {
                mBar.addNotification(key, notification);
            } catch (RemoteException ex) {
            }
        }
        return key;
    }
}
Also used : IBinder(android.os.IBinder) Binder(android.os.Binder) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 14 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class TelephonyRegistry method listen.

@Override
public void listen(String pkgForDebug, IPhoneStateListener callback, int events, boolean notifyNow) {
    int callerUid = UserHandle.getCallingUserId();
    int myUid = UserHandle.myUserId();
    if (DBG) {
        Slog.d(TAG, "listen: E pkg=" + pkgForDebug + " events=0x" + Integer.toHexString(events) + " myUid=" + myUid + " callerUid=" + callerUid);
    }
    if (events != 0) {
        /* Checks permission and throws Security exception */
        checkListenerPermission(events);
        synchronized (mRecords) {
            // register
            Record r = null;
            find_and_add: {
                IBinder b = callback.asBinder();
                final int N = mRecords.size();
                for (int i = 0; i < N; i++) {
                    r = mRecords.get(i);
                    if (b == r.binder) {
                        break find_and_add;
                    }
                }
                r = new Record();
                r.binder = b;
                r.callback = callback;
                r.pkgForDebug = pkgForDebug;
                r.callerUid = callerUid;
                mRecords.add(r);
                if (DBG)
                    Slog.i(TAG, "listen: add new record=" + r);
            }
            int send = events & (events ^ r.events);
            r.events = events;
            if (notifyNow) {
                if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
                    try {
                        r.callback.onServiceStateChanged(new ServiceState(mServiceState));
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
                    try {
                        int gsmSignalStrength = mSignalStrength.getGsmSignalStrength();
                        r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 : gsmSignalStrength));
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
                    try {
                        r.callback.onMessageWaitingIndicatorChanged(mMessageWaiting);
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
                    try {
                        r.callback.onCallForwardingIndicatorChanged(mCallForwarding);
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
                    try {
                        if (DBG_LOC)
                            Slog.d(TAG, "listen: mCellLocation=" + mCellLocation);
                        r.callback.onCellLocationChanged(new Bundle(mCellLocation));
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
                    try {
                        r.callback.onCallStateChanged(mCallState, mCallIncomingNumber);
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
                    try {
                        r.callback.onDataConnectionStateChanged(mDataConnectionState, mDataConnectionNetworkType);
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
                    try {
                        r.callback.onDataActivity(mDataActivity);
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
                    try {
                        r.callback.onSignalStrengthsChanged(mSignalStrength);
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
                    try {
                        r.callback.onOtaspChanged(mOtaspMode);
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
                if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
                    try {
                        if (DBG_LOC)
                            Slog.d(TAG, "listen: mCellInfo=" + mCellInfo);
                        r.callback.onCellInfoChanged(mCellInfo);
                    } catch (RemoteException ex) {
                        remove(r.binder);
                    }
                }
            }
        }
    } else {
        remove(callback.asBinder());
    }
}
Also used : IBinder(android.os.IBinder) ServiceState(android.telephony.ServiceState) Bundle(android.os.Bundle) RemoteException(android.os.RemoteException)

Example 15 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class NotificationManagerService method checkListenerToken.

// -- APIs to support listeners clicking/clearing notifications --
private NotificationListenerInfo checkListenerToken(INotificationListener listener) {
    final IBinder token = listener.asBinder();
    final int N = mListeners.size();
    for (int i = 0; i < N; i++) {
        final NotificationListenerInfo info = mListeners.get(i);
        if (info.listener.asBinder() == token)
            return info;
    }
    throw new SecurityException("Disallowed call from unknown listener: " + listener);
}
Also used : IBinder(android.os.IBinder)

Aggregations

IBinder (android.os.IBinder)1139 RemoteException (android.os.RemoteException)553 Intent (android.content.Intent)186 ComponentName (android.content.ComponentName)166 ServiceConnection (android.content.ServiceConnection)127 Parcel (android.os.Parcel)112 PendingIntent (android.app.PendingIntent)69 Point (android.graphics.Point)67 Bundle (android.os.Bundle)56 IOException (java.io.IOException)53 UserHandle (android.os.UserHandle)50 Binder (android.os.Binder)47 Message (android.os.Message)37 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)35 Handler (android.os.Handler)33 AndroidRuntimeException (android.util.AndroidRuntimeException)33 ArrayList (java.util.ArrayList)30 IUsbManager (android.hardware.usb.IUsbManager)29 Context (android.content.Context)28 Messenger (android.os.Messenger)26