Search in sources :

Example 41 with IIntentReceiver

use of android.content.IIntentReceiver in project android_frameworks_base by ResurrectionRemix.

the class ContextImpl method sendStickyOrderedBroadcast.

@Override
@Deprecated
public void sendStickyOrderedBroadcast(Intent intent, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras) {
    warnIfCallingFromSystemProcess();
    IIntentReceiver rd = null;
    if (resultReceiver != null) {
        if (mPackageInfo != null) {
            if (scheduler == null) {
                scheduler = mMainThread.getHandler();
            }
            rd = mPackageInfo.getReceiverDispatcher(resultReceiver, getOuterContext(), scheduler, mMainThread.getInstrumentation(), false);
        } else {
            if (scheduler == null) {
                scheduler = mMainThread.getHandler();
            }
            rd = new LoadedApk.ReceiverDispatcher(resultReceiver, getOuterContext(), scheduler, null, false).getIIntentReceiver();
        }
    }
    String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
    try {
        intent.prepareToLeaveProcess(this);
        ActivityManagerNative.getDefault().broadcastIntent(mMainThread.getApplicationThread(), intent, resolvedType, rd, initialCode, initialData, initialExtras, null, AppOpsManager.OP_NONE, null, true, true, getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
Also used : IIntentReceiver(android.content.IIntentReceiver) RemoteException(android.os.RemoteException)

Example 42 with IIntentReceiver

use of android.content.IIntentReceiver in project android_frameworks_base by ResurrectionRemix.

the class UserController method stopSingleUserLocked.

private void stopSingleUserLocked(final int userId, final IStopUserCallback callback) {
    if (DEBUG_MU)
        Slog.i(TAG, "stopSingleUserLocked userId=" + userId);
    final UserState uss = mStartedUsers.get(userId);
    if (uss == null) {
        // callback if requested.
        if (callback != null) {
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    try {
                        callback.userStopped(userId);
                    } catch (RemoteException e) {
                    }
                }
            });
        }
        return;
    }
    if (callback != null) {
        uss.mStopCallbacks.add(callback);
    }
    if (uss.state != UserState.STATE_STOPPING && uss.state != UserState.STATE_SHUTDOWN) {
        uss.setState(UserState.STATE_STOPPING);
        getUserManagerInternal().setUserState(userId, uss.state);
        updateStartedUserArrayLocked();
        long ident = Binder.clearCallingIdentity();
        try {
            // We are going to broadcast ACTION_USER_STOPPING and then
            // once that is done send a final ACTION_SHUTDOWN and then
            // stop the user.
            final Intent stoppingIntent = new Intent(Intent.ACTION_USER_STOPPING);
            stoppingIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
            stoppingIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
            stoppingIntent.putExtra(Intent.EXTRA_SHUTDOWN_USERSPACE_ONLY, true);
            // This is the result receiver for the initial stopping broadcast.
            final IIntentReceiver stoppingReceiver = new IIntentReceiver.Stub() {

                @Override
                public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
                    mHandler.post(new Runnable() {

                        @Override
                        public void run() {
                            finishUserStopping(userId, uss);
                        }
                    });
                }
            };
            // Clear broadcast queue for the user to avoid delivering stale broadcasts
            mService.clearBroadcastQueueForUserLocked(userId);
            // Kick things off.
            mService.broadcastIntentLocked(null, null, stoppingIntent, null, stoppingReceiver, 0, null, null, new String[] { INTERACT_ACROSS_USERS }, AppOpsManager.OP_NONE, null, true, false, MY_PID, SYSTEM_UID, UserHandle.USER_ALL);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }
}
Also used : Bundle(android.os.Bundle) IIntentReceiver(android.content.IIntentReceiver) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Example 43 with IIntentReceiver

use of android.content.IIntentReceiver in project android_frameworks_base by crdroidandroid.

the class ContextImpl method sendOrderedBroadcastAsUser.

@Override
public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission, int appOp, Bundle options, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras) {
    IIntentReceiver rd = null;
    if (resultReceiver != null) {
        if (mPackageInfo != null) {
            if (scheduler == null) {
                scheduler = mMainThread.getHandler();
            }
            rd = mPackageInfo.getReceiverDispatcher(resultReceiver, getOuterContext(), scheduler, mMainThread.getInstrumentation(), false);
        } else {
            if (scheduler == null) {
                scheduler = mMainThread.getHandler();
            }
            rd = new LoadedApk.ReceiverDispatcher(resultReceiver, getOuterContext(), scheduler, null, false).getIIntentReceiver();
        }
    }
    String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
    String[] receiverPermissions = receiverPermission == null ? null : new String[] { receiverPermission };
    try {
        intent.prepareToLeaveProcess(this);
        ActivityManagerNative.getDefault().broadcastIntent(mMainThread.getApplicationThread(), intent, resolvedType, rd, initialCode, initialData, initialExtras, receiverPermissions, appOp, options, true, false, user.getIdentifier());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
Also used : IIntentReceiver(android.content.IIntentReceiver) RemoteException(android.os.RemoteException)

Example 44 with IIntentReceiver

use of android.content.IIntentReceiver in project android_frameworks_base by crdroidandroid.

the class UserController method stopSingleUserLocked.

private void stopSingleUserLocked(final int userId, final IStopUserCallback callback) {
    if (DEBUG_MU)
        Slog.i(TAG, "stopSingleUserLocked userId=" + userId);
    final UserState uss = mStartedUsers.get(userId);
    if (uss == null) {
        // callback if requested.
        if (callback != null) {
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    try {
                        callback.userStopped(userId);
                    } catch (RemoteException e) {
                    }
                }
            });
        }
        return;
    }
    if (callback != null) {
        uss.mStopCallbacks.add(callback);
    }
    if (uss.state != UserState.STATE_STOPPING && uss.state != UserState.STATE_SHUTDOWN) {
        uss.setState(UserState.STATE_STOPPING);
        getUserManagerInternal().setUserState(userId, uss.state);
        updateStartedUserArrayLocked();
        long ident = Binder.clearCallingIdentity();
        try {
            // We are going to broadcast ACTION_USER_STOPPING and then
            // once that is done send a final ACTION_SHUTDOWN and then
            // stop the user.
            final Intent stoppingIntent = new Intent(Intent.ACTION_USER_STOPPING);
            stoppingIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
            stoppingIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
            stoppingIntent.putExtra(Intent.EXTRA_SHUTDOWN_USERSPACE_ONLY, true);
            // This is the result receiver for the initial stopping broadcast.
            final IIntentReceiver stoppingReceiver = new IIntentReceiver.Stub() {

                @Override
                public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
                    mHandler.post(new Runnable() {

                        @Override
                        public void run() {
                            finishUserStopping(userId, uss);
                        }
                    });
                }
            };
            // Clear broadcast queue for the user to avoid delivering stale broadcasts
            mService.clearBroadcastQueueForUserLocked(userId);
            // Kick things off.
            mService.broadcastIntentLocked(null, null, stoppingIntent, null, stoppingReceiver, 0, null, null, new String[] { INTERACT_ACROSS_USERS }, AppOpsManager.OP_NONE, null, true, false, MY_PID, SYSTEM_UID, UserHandle.USER_ALL);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }
}
Also used : Bundle(android.os.Bundle) IIntentReceiver(android.content.IIntentReceiver) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Example 45 with IIntentReceiver

use of android.content.IIntentReceiver in project android_frameworks_base by crdroidandroid.

the class UserController method finishUserStopping.

void finishUserStopping(final int userId, final UserState uss) {
    // On to the next.
    final Intent shutdownIntent = new Intent(Intent.ACTION_SHUTDOWN);
    // This is the result receiver for the final shutdown broadcast.
    final IIntentReceiver shutdownReceiver = new IIntentReceiver.Stub() {

        @Override
        public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    finishUserStopped(uss);
                }
            });
        }
    };
    synchronized (mService) {
        if (uss.state != UserState.STATE_STOPPING) {
            // Whoops, we are being started back up.  Abort, abort!
            return;
        }
        uss.setState(UserState.STATE_SHUTDOWN);
    }
    getUserManagerInternal().setUserState(userId, uss.state);
    mService.mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_RUNNING_FINISH, Integer.toString(userId), userId);
    mService.mSystemServiceManager.stopUser(userId);
    synchronized (mService) {
        mService.broadcastIntentLocked(null, null, shutdownIntent, null, shutdownReceiver, 0, null, null, null, AppOpsManager.OP_NONE, null, true, false, MY_PID, SYSTEM_UID, userId);
    }
}
Also used : Bundle(android.os.Bundle) IIntentReceiver(android.content.IIntentReceiver) Intent(android.content.Intent)

Aggregations

IIntentReceiver (android.content.IIntentReceiver)45 RemoteException (android.os.RemoteException)39 Intent (android.content.Intent)19 Bundle (android.os.Bundle)13 PendingIntent (android.app.PendingIntent)3 ComponentName (android.content.ComponentName)2 ActivityInfo (android.content.pm.ActivityInfo)2 ApplicationInfo (android.content.pm.ApplicationInfo)2 ResolveInfo (android.content.pm.ResolveInfo)2 Message (android.os.Message)2 RemoteCallbackList (android.os.RemoteCallbackList)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IntentFilter (android.content.IntentFilter)1 IBinder (android.os.IBinder)1 IInterface (android.os.IInterface)1 WeakReference (java.lang.ref.WeakReference)1