Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03bc4b84 authored by Jaewan Kim's avatar Jaewan Kim Committed by android-build-merger
Browse files

Merge \\"MediaResourceMonitor: Send broadcast to current users\\" into nyc-mr1-dev am: 7f4f52cb

am: 60b85827

Change-Id: Ie7b2e22c866fde26a4ee99e8b168b5fdbfd21d80
parents ae33b776 60b85827
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.media.IMediaResourceMonitor;
import android.os.Binder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
import android.util.Slog;
import com.android.server.SystemService;
@@ -59,12 +60,20 @@ public class MediaResourceMonitorService extends SystemService {
            final long identity = Binder.clearCallingIdentity();
            try {
                String pkgNames[] = getPackageNamesFromPid(pid);
                if (pkgNames != null) {
                if (pkgNames == null) {
                    return;
                }
                UserManager manager = (UserManager) getContext().getSystemService(
                        Context.USER_SERVICE);
                int[] userIds = manager.getEnabledProfileIds(ActivityManager.getCurrentUser());
                if (userIds == null || userIds.length == 0) {
                    return;
                }
                Intent intent = new Intent(Intent.ACTION_MEDIA_RESOURCE_GRANTED);
                intent.putExtra(Intent.EXTRA_PACKAGES, pkgNames);
                intent.putExtra(Intent.EXTRA_MEDIA_RESOURCE_TYPE, type);
                    getContext().sendBroadcastAsUser(intent,
                            new UserHandle(ActivityManager.getCurrentUser()),
                for (int userId : userIds) {
                    getContext().sendBroadcastAsUser(intent, UserHandle.of(userId),
                            android.Manifest.permission.RECEIVE_MEDIA_RESOURCE_USAGE);
                }
            } finally {