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

Commit 3c3d3081 authored by Android (Google) Code Review's avatar Android (Google) Code Review Committed by The Android Open Source Project
Browse files

am 727f36c6: Merge change 4265 into donut

Merge commit '727f36c6'

* commit '727f36c6':
  process: Fix bug where if a thread exited while we were changing its control
  Fix the build: Remove ADD_SYSTEM_SERVICE, which I had accidentally
parents 29930a1c 727f36c6
Loading
Loading
Loading
Loading
+16 −24
Original line number Diff line number Diff line
@@ -50,8 +50,6 @@ pid_t gettid() { return syscall(__NR_gettid);}
#undef __KERNEL__
#endif

#define ENABLE_CGROUP_DEBUG 0

/*
 * List of cgroup names which map to ANDROID_TGROUP_ values in Thread.h
 * and Process.java
@@ -205,40 +203,32 @@ static int add_pid_to_cgroup(int pid, int grp)
    sprintf(path, "/dev/cpuctl/%s/tasks",
           (cgroup_names[grp] ? cgroup_names[grp] : ""));

    if ((fd = open(path, O_WRONLY)) < 0) {
        LOGE("Error opening '%s' (%s)", path, strerror(errno));
    if ((fd = open(path, O_WRONLY)) < 0)
        return -1;
    }

    sprintf(text, "%d", pid);
    if (write(fd, text, strlen(text)) < 0) {
        LOGE("Error writing to '%s' (%s)", path, strerror(errno));
        close(fd);
        return -1;
    }

    close(fd);

#if ENABLE_CGROUP_DEBUG
    LOGD("Pid %d sucessfully added to '%s'", pid, path);
#endif
    return 0;
}

void android_os_Process_setThreadGroup(JNIEnv* env, jobject clazz, int pid, jint grp)
{
#if ENABLE_CGROUP_DEBUG
    LOGD("android_os_Process_setThreadGroup(%d, %d)", pid, grp);
#endif

    if (grp > ANDROID_TGROUP_MAX || grp < 0) { 
        signalExceptionForGroupError(env, clazz, EINVAL);
        return;
    }

    if (add_pid_to_cgroup(pid, grp))
    if (add_pid_to_cgroup(pid, grp)) {
        // If the thread exited on us, don't generate an exception
        if (errno != ESRCH && errno != ENOENT)
            signalExceptionForGroupError(env, clazz, errno);
    }
}

void android_os_Process_setProcessGroup(JNIEnv* env, jobject clazz, int pid, jint grp) 
{
@@ -247,10 +237,6 @@ void android_os_Process_setProcessGroup(JNIEnv* env, jobject clazz, int pid, jin
    char proc_path[255];
    struct dirent *de;

#if ENABLE_CGROUP_DEBUG
    LOGD("android_os_Process_setProcessGroup(%d, %d)", pid, grp);
#endif

    if (grp > ANDROID_TGROUP_MAX || grp < 0) { 
        signalExceptionForGroupError(env, clazz, EINVAL);
        return;
@@ -258,6 +244,8 @@ void android_os_Process_setProcessGroup(JNIEnv* env, jobject clazz, int pid, jin

    sprintf(proc_path, "/proc/%d/task", pid);
    if (!(d = opendir(proc_path))) {
        // If the process exited on us, don't generate an exception
        if (errno != ENOENT)
            signalExceptionForGroupError(env, clazz, errno);
        return;
    }
@@ -265,12 +253,16 @@ void android_os_Process_setProcessGroup(JNIEnv* env, jobject clazz, int pid, jin
    while ((de = readdir(d))) {
        if (de->d_name[0] == '.')
            continue;

        if (add_pid_to_cgroup(atoi(de->d_name), grp)) {
            // If the thread exited on us, ignore it and keep going
            if (errno != ESRCH && errno != ENOENT) {
                signalExceptionForGroupError(env, clazz, errno);
                closedir(d);
                return;
            }
        }
    }
    closedir(d);
}

+0 −8
Original line number Diff line number Diff line
@@ -745,14 +745,6 @@
        android:description="@string/permdesc_forceBack"
        android:protectionLevel="signature" />

    <!-- Allows an application to publish system-level services.  Such services
         can only be published from processes that never go away, so this is
         not something that any normal application can do. -->
    <permission android:name="android.permission.ADD_SYSTEM_SERVICE"
        android:label="@string/permlab_addSystemService"
        android:description="@string/permdesc_addSystemService"
        android:protectionLevel="signature" />

    <!-- Allows an application to update device statistics. Not for
         use by third party apps. -->
    <permission android:name="android.permission.UPDATE_DEVICE_STATS"
+0 −2
Original line number Diff line number Diff line
@@ -177,8 +177,6 @@
    <string name="permdesc_setProcessLimit">"Umožňuje aplikaci řídit maximální počet spuštěných procesů. Běžné aplikace toto nastavení nikdy nevyužívají."</string>
    <string name="permlab_setAlwaysFinish">"zavření všech aplikací na pozadí"</string>
    <string name="permdesc_setAlwaysFinish">"Umožňuje aplikaci ovládat, zda jsou činnosti vždy dokončeny po přesunutí do pozadí. Běžné aplikace toto nastavení nikdy nevyužívají."</string>
    <string name="permlab_fotaUpdate">"automatická instalace aktualizací systému"</string>
    <string name="permdesc_fotaUpdate">"Umožňuje aplikaci přijímat oznámení o čekajících aktualizacích systému a spouštět jejich instalaci. Škodlivé aplikace mohou díky tomuto nastavení poškodit systém pomocí neoprávněných aktualizací nebo celkově narušovat proces aktualizace."</string>
    <string name="permlab_batteryStats">"změna statistických údajů o baterii"</string>
    <string name="permdesc_batteryStats">"Umožňuje změnu shromážděných statistických údajů o baterii. Není určeno pro běžné aplikace."</string>
    <string name="permlab_internalSystemWindow">"zobrazení nepovolených oken"</string>
+0 −2
Original line number Diff line number Diff line
@@ -177,8 +177,6 @@
    <string name="permdesc_setProcessLimit">"Ermöglicht einer Anwendung, die maximale Anzahl an laufenden Prozessen zu steuern. Wird nicht für normale Anwendungen benötigt."</string>
    <string name="permlab_setAlwaysFinish">"alle Anwendungen im Hintergrund schließen"</string>
    <string name="permdesc_setAlwaysFinish">"Überlässt einer Anwendung die Entscheidung, ob Aktivitäten beendet werden, sobald Sie in den Hintergrund rücken. Wird nicht für normale Anwendungen benötigt."</string>
    <string name="permlab_fotaUpdate">"System-Updates automatisch installieren"</string>
    <string name="permdesc_fotaUpdate">"Ermöglicht einer Anwendung, Benachrichtigungen zu ausstehenden System-Updates zu erhalten und deren Installation einzuleiten. Schädliche Anwendungen können so das System durch nicht autorisierte Updates beschädigen oder in den Update-Prozess eingreifen."</string>
    <string name="permlab_batteryStats">"Akku-Daten ändern"</string>
    <string name="permdesc_batteryStats">"Ermöglicht die Änderung von gesammelten Akku-Daten. Nicht für normale Anwendungen vorgesehen."</string>
    <string name="permlab_internalSystemWindow">"nicht autorisierte Fenster anzeigen"</string>
+0 −4
Original line number Diff line number Diff line
@@ -314,10 +314,6 @@
    <skip />
    <!-- no translation found for permdesc_setAlwaysFinish (2437195869854312148) -->
    <skip />
    <!-- no translation found for permlab_fotaUpdate (1813039882829307079) -->
    <skip />
    <!-- no translation found for permdesc_fotaUpdate (2544137712607584763) -->
    <skip />
    <!-- no translation found for permlab_batteryStats (1598947993704535568) -->
    <skip />
    <!-- no translation found for permdesc_batteryStats (6247598531831307989) -->
Loading