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

Commit 5c84a384 authored by Susheel Yadagiri's avatar Susheel Yadagiri Committed by Linux Build Service Account
Browse files

Enable NSRM (Network Socket Request Manager).

NSRM is a feature to synchronize app socket requests
to reduce network signalling and there by save power.

Change-Id: Ic34b9c54404ba2156701da1f63232013978bf3a4
CRs-Fixed: 997493
parent 9f74ab06
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -37,4 +37,6 @@ interface IAlarmManager {
    void remove(in PendingIntent operation, in IAlarmListener listener);
    long getNextWakeFromIdleTime();
    AlarmManager.AlarmClockInfo getNextAlarmClock(int userId);
    // update the uids being synchronized by network socket request manager
    void updateBlockedUids(int uid, boolean isBlocked);
}
+2 −0
Original line number Diff line number Diff line
@@ -40,4 +40,6 @@ interface IDeviceIdleController {
    void exitIdle(String reason);
    boolean registerMaintenanceActivityListener(IMaintenanceActivityListener listener);
    void unregisterMaintenanceActivityListener(IMaintenanceActivityListener listener);
    int getIdleStateDetailed();
    int getLightIdleStateDetailed();
}
+2 −0
Original line number Diff line number Diff line
@@ -65,4 +65,6 @@ interface IPowerManager

    // sets the attention light (used by phone app only)
    void setAttentionLight(boolean on, int color);
    // update the uids being synchronized by network socket request manager
    void updateBlockedUids(int uid, boolean isBlocked);
}
+23 −4
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ class AlarmManagerService extends SystemService {
    private long mLastWakeup;
    int mBroadcastRefCount = 0;
    PowerManager.WakeLock mWakeLock;
    private QCNsrmAlarmExtension qcNsrmExt = new QCNsrmAlarmExtension();
    boolean mLastWakeLockUnimportantForLogging;
    ArrayList<Alarm> mPendingNonWakeupAlarms = new ArrayList<>();
    ArrayList<InFlight> mInFlight = new ArrayList<>();
@@ -1353,6 +1354,16 @@ class AlarmManagerService extends SystemService {

            dumpImpl(pw);
        }

        @Override
        /* updates the blocked uids, so if a wake lock is acquired to only fire
         * alarm for it, it can be released.
         */
        public void updateBlockedUids(int uid, boolean isBlocked) {
            synchronized(mLock) {
                qcNsrmExt.processBlockedUids(uid, isBlocked, mWakeLock);
            }
        }
    };

    public final class LocalService {
@@ -2582,11 +2593,10 @@ class AlarmManagerService extends SystemService {
                mWakeLock.setWorkSource(new WorkSource(uid));
                return;
            }
        } catch (Exception e) {
        }

            // Something went wrong; fall back to attributing the lock to the OS
            mWakeLock.setWorkSource(null);
        } catch (Exception e) {
        }
    }

    private class AlarmHandler extends Handler {
@@ -2884,9 +2894,13 @@ class AlarmManagerService extends SystemService {
                updateStatsLocked(inflight);
            }
            mBroadcastRefCount--;
            qcNsrmExt.removeTriggeredUid(inflight.mUid);

            if (mBroadcastRefCount == 0) {
                mHandler.obtainMessage(AlarmHandler.REPORT_ALARMS_ACTIVE, 0).sendToTarget();
                if (mWakeLock.isHeld()) {
                    mWakeLock.release();
                }
                if (mInFlight.size() > 0) {
                    mLog.w("Finished all dispatches with " + mInFlight.size()
                            + " remaining inflights");
@@ -3028,7 +3042,9 @@ class AlarmManagerService extends SystemService {
                setWakelockWorkSource(alarm.operation, alarm.workSource,
                        alarm.type, alarm.statsTag, (alarm.operation == null) ? alarm.uid : -1,
                        true);
                if (!mWakeLock.isHeld()) {
                mWakeLock.acquire();
                }
                mHandler.obtainMessage(AlarmHandler.REPORT_ALARMS_ACTIVE, 1).sendToTarget();
            }
            final InFlight inflight = new InFlight(AlarmManagerService.this,
@@ -3036,6 +3052,9 @@ class AlarmManagerService extends SystemService {
                    alarm.packageName, alarm.type, alarm.statsTag, nowELAPSED);
            mInFlight.add(inflight);
            mBroadcastRefCount++;
            qcNsrmExt.addTriggeredUid((alarm.operation != null) ?
                                    alarm.operation.getCreatorUid() :
                                    alarm.uid);

            if (allowWhileIdle) {
                // Record the last time this uid handled an ALLOW_WHILE_IDLE alarm.
+12 −0
Original line number Diff line number Diff line
@@ -1189,6 +1189,18 @@ public class DeviceIdleController extends SystemService
            return isPowerSaveWhitelistAppInternal(name);
        }

        @Override public int getIdleStateDetailed() {
            getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
                    null);
            return mState;
        }

        @Override public int getLightIdleStateDetailed() {
            getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
                    null);
            return mLightState;
        }

        @Override public void addPowerSaveTempWhitelistApp(String packageName, long duration,
                int userId, String reason) throws RemoteException {
            addPowerSaveTempWhitelistAppChecked(packageName, duration, userId, reason);
Loading