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

Commit dbff7971 authored by Wenhao Wang's avatar Wenhao Wang
Browse files

Temporarily disable user consent check

This CL will grant permission for all requests to access logd.
It's a short-term solution to unblock some automated tests.

Bug: 196856709
Bug: 218391941
Bug: 218267535
Test: Safetynet test
Test: health/mpts/heavyweight
Ignore-AOSP-First: pending fix for logcat privacy issue

Change-Id: I2119e26454a95791d52ec9183abc615dd8c0c5cf
parent 07e70505
Loading
Loading
Loading
Loading
+6 −54
Original line number Diff line number Diff line
@@ -329,8 +329,7 @@ public final class LogcatManagerService extends SystemService {

            if (mStart) {

                // TODO See the comments of ALLOWABLE_TESTING_PACKAGES.
                if (isAllowableTestingPackage(mUid)) {
                // TODO Temporarily approve all the requests to unblock testing failures.
                try {
                    getLogdService().approve(mUid, mGid, mPid, mFd);
                } catch (RemoteException e) {
@@ -338,53 +337,6 @@ public final class LogcatManagerService extends SystemService {
                }
                return;
            }

                // If the access request is coming from adb shell, approve the logd access
                if (mUid == AID_SHELL_UID) {
                    try {
                        getLogdService().approve(mUid, mGid, mPid, mFd);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                    return;
                }

                final int procState = LocalServices.getService(ActivityManagerInternal.class)
                        .getUidProcessState(mUid);
                // If the process is foreground, send a notification for user consent
                if (procState <= ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE) {
                    String clientInfo = getClientInfo(mUid, mGid, mPid, mFd);
                    sendNotification(0, clientInfo, mUid, mGid, mPid, mFd);
                } else {
                    /**
                     * If the process is background, add a background process change listener and
                     * monitor if the process status changes.
                     * To avoid clients registering multiple listeners, we limit the number of
                     * maximum listeners to MAX_UID_IMPORTANCE_COUNT_LISTENER.
                     **/
                    if (mActivityManager == null) {
                        return;
                    }

                    synchronized (LogcatManagerService.this) {
                        if (sUidImportanceListenerCount < MAX_UID_IMPORTANCE_COUNT_LISTENER) {
                            // Trigger addOnUidImportanceListener when there is an update from
                            // the importance of the process
                            mActivityManager.addOnUidImportanceListener(new UidImportanceListener(
                                    mUid, mGid, mPid, mFd,
                                    RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE),
                                    RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE);
                            sUidImportanceListenerCount++;
                        } else {
                            try {
                                getLogdService().decline(mUid, mGid, mPid, mFd);
                            } catch (RemoteException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            }
        }
    }