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

Commit 3c3155ab authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

Merge "Fix Power Control widget"

parents 06c51e2f 67cf7d31
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -911,6 +911,19 @@ class ContextImpl extends Context {
        }
    }

    /** @hide */
    @Override
    public void sendBroadcast(Intent intent, int userId) {
        String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
        try {
            intent.setAllowFds(false);
            ActivityManagerNative.getDefault().broadcastIntent(mMainThread.getApplicationThread(),
                    intent, resolvedType, null, Activity.RESULT_OK, null, null, null, false, false,
                    userId);
        } catch (RemoteException e) {
        }
    }

    @Override
    public void sendBroadcast(Intent intent, String receiverPermission) {
        String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
+10 −0
Original line number Diff line number Diff line
@@ -904,6 +904,16 @@ public abstract class Context {
     */
    public abstract void sendBroadcast(Intent intent);

    /**
     * Same as #sendBroadcast(Intent intent), but for a specific user. Used by the system only.
     * @param intent the intent to broadcast
     * @param userId user to send the intent to
     * @hide
     */
    public void sendBroadcast(Intent intent, int userId) {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

    /**
     * Broadcast the given intent to all interested BroadcastReceivers, allowing
     * an optional required permission to be enforced.  This
+6 −0
Original line number Diff line number Diff line
@@ -294,6 +294,12 @@ public class ContextWrapper extends Context {
        mBase.sendBroadcast(intent);
    }

    /** @hide */
    @Override
    public void sendBroadcast(Intent intent, int userId) {
        mBase.sendBroadcast(intent, userId);
    }

    @Override
    public void sendBroadcast(Intent intent, String receiverPermission) {
        mBase.sendBroadcast(intent, receiverPermission);
+6 −9
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ class AppWidgetServiceImpl {
                Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_DELETED);
                intent.setComponent(p.info.provider);
                intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id.appWidgetId);
                mContext.sendBroadcast(intent);
                mContext.sendBroadcast(intent, mUserId);
                if (p.instances.size() == 0) {
                    // cancel the future updates
                    cancelBroadcasts(p);
@@ -471,7 +471,7 @@ class AppWidgetServiceImpl {
                    // send the broacast saying that the provider is not in use any more
                    intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_DISABLED);
                    intent.setComponent(p.info.provider);
                    mContext.sendBroadcast(intent);
                    mContext.sendBroadcast(intent, mUserId);
                }
            }
        }
@@ -515,8 +515,6 @@ class AppWidgetServiceImpl {
                            + " safe mode: " + provider);
                }

                Binder.restoreCallingIdentity(ident);

                id.provider = p;
                p.instances.add(id);
                int instancesSize = p.instances.size();
@@ -1066,7 +1064,7 @@ class AppWidgetServiceImpl {
    void sendEnableIntentLocked(Provider p) {
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_ENABLED);
        intent.setComponent(p.info.provider);
        mContext.sendBroadcast(intent);
        mContext.sendBroadcast(intent, mUserId);
    }

    void sendUpdateIntentLocked(Provider p, int[] appWidgetIds) {
@@ -1074,7 +1072,7 @@ class AppWidgetServiceImpl {
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
            intent.setComponent(p.info.provider);
            mContext.sendBroadcast(intent);
            mContext.sendBroadcast(intent, mUserId);
        }
    }

@@ -1477,12 +1475,11 @@ class AppWidgetServiceImpl {
    }

    AtomicFile savedStateFile() {
        int userId = UserId.getCallingUserId();
        File dir = new File("/data/system/users/" + userId);
        File dir = new File("/data/system/users/" + mUserId);
        File settingsFile = new File(dir, SETTINGS_FILENAME);
        if (!dir.exists()) {
            dir.mkdirs();
            if (userId == 0) {
            if (mUserId == 0) {
                // Migrate old data
                File oldFile = new File("/data/system/" + SETTINGS_FILENAME);
                // Method doesn't throw an exception on failure. Ignore any errors
+6 −0
Original line number Diff line number Diff line
@@ -267,6 +267,12 @@ public class MockContext extends Context {
        throw new UnsupportedOperationException();
    }

    /** @hide */
    @Override
    public void sendBroadcast(Intent intent, int userId) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void sendBroadcast(Intent intent, String receiverPermission) {
        throw new UnsupportedOperationException();