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

Commit 8c7d565a authored by vagdevi's avatar vagdevi Committed by Vagdevi Kondeti
Browse files

Fix WorkSource clientId detection

Initialize mActiveWakeLockWorkSource so there can be no chance
of two identical worksources being added/removed with each other.

In existing WorkSource logic, if worksources do equal each other,
then size decrements while uid and name exist - this causes
the clientId to be null since it is empty, even though the
clientId value exists. Test added in WorkSourceTest at ag/4627499
and aosp/729235.

Bug: 111652977
Test: locally, ag/4627499, aosp/729235
Change-Id: If23a20f26d916ef059ff02b727f8560de5f68e00
parent 6ca66f59
Loading
Loading
Loading
Loading
+5 −12
Original line number Diff line number Diff line
@@ -480,6 +480,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
        mWakeLockCount = 0;
        mRILDefaultWorkSource = new WorkSource(context.getApplicationInfo().uid,
                context.getPackageName());
        mActiveWakelockWorkSource = new WorkSource();

        TelephonyDevController tdc = TelephonyDevController.getInstance();
        tdc.registerRIL(this);
@@ -4285,11 +4286,7 @@ public class RIL extends BaseCommands implements CommandsInterface {

                        String clientId = rr.getWorkSourceClientId();
                        if (!mClientWakelockTracker.isClientActive(clientId)) {
                            if (mActiveWakelockWorkSource != null) {
                            mActiveWakelockWorkSource.add(rr.mWorkSource);
                            } else {
                                mActiveWakelockWorkSource = rr.mWorkSource;
                            }
                            mWakeLock.setWorkSource(mActiveWakelockWorkSource);
                        }

@@ -4346,12 +4343,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
                                rr.mRequest, rr.mSerial,
                                (mWakeLockCount > 1) ? mWakeLockCount - 1 : 0);
                        String clientId = rr.getWorkSourceClientId();
                        if (!mClientWakelockTracker.isClientActive(clientId)
                                && (mActiveWakelockWorkSource != null)) {
                        if (!mClientWakelockTracker.isClientActive(clientId)) {
                            mActiveWakelockWorkSource.remove(rr.mWorkSource);
                            if (mActiveWakelockWorkSource.size() == 0) {
                                mActiveWakelockWorkSource = null;
                            }
                            mWakeLock.setWorkSource(mActiveWakelockWorkSource);
                        }

@@ -4384,7 +4377,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                mWakeLockCount = 0;
                mWakeLock.release();
                mClientWakelockTracker.stopTrackingAll();
                mActiveWakelockWorkSource = null;
                mActiveWakelockWorkSource = new WorkSource();
                return true;
            }
        } else {
+1 −2
Original line number Diff line number Diff line
@@ -115,9 +115,8 @@ public class RILRequest {
     */
    // @VisibleForTesting
    public static RILRequest obtain(int request, Message result, WorkSource workSource) {
        RILRequest rr = null;
        RILRequest rr = obtain(request, result);

        rr = obtain(request, result);
        if (workSource != null) {
            rr.mWorkSource = workSource;
            rr.mClientId = rr.getWorkSourceClientId();