diff --git a/LeOS/ConnectivityCheckPreferenceController.java b/LeOS/ConnectivityCheckPreferenceController.java deleted file mode 100644 index 1d829637..00000000 --- a/LeOS/ConnectivityCheckPreferenceController.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.network; - -import android.content.ContentResolver; -import android.content.Context; -import android.content.res.Resources; -import android.database.ContentObserver; -import android.net.LinkProperties; -import android.net.Network; -import android.os.Handler; -import android.os.Looper; -import android.os.UserHandle; -import android.os.UserManager; -import android.provider.Settings; -import androidx.preference.ListPreference; -import androidx.preference.Preference; -import androidx.preference.PreferenceScreen; -import com.android.internal.util.ArrayUtils; -import com.android.settings.R; -import com.android.settings.core.BasePreferenceController; -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; -import com.android.settingslib.RestrictedLockUtilsInternal; -import com.android.settingslib.core.lifecycle.events.OnResume; - -public class ConnectivityCheckPreferenceController - extends BasePreferenceController - implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener, - OnResume { - - // imported defaults from AOSP NetworkStack - private static final String STANDARD_HTTPS_URL = - "http://captiveportal.kuketz.de/generate_204"; - private static final String STANDARD_HTTP_URL = - "http://captiveportal.kuketz.de/generate_204"; - private static final String STANDARD_FALLBACK_URL = - "http://captiveportal.kuketz.de/gen_204"; - private static final String STANDARD_OTHER_FALLBACK_URLS = - "http://captiveportal.kuketz.de/generate_204"; - - // GrapheneOS - private static final String GRAPHENEOS_CAPTIVE_PORTAL_HTTPS_URL = - "https://connectivitycheck.grapheneos.network/generate_204"; - private static final String GRAPHENEOS_CAPTIVE_PORTAL_HTTP_URL = - "http://connectivitycheck.grapheneos.network/generate_204"; - private static final String GRAPHENEOS_CAPTIVE_PORTAL_FALLBACK_URL = - "http://grapheneos.online/gen_204"; - private static final String GRAPHENEOS_CAPTIVE_PORTAL_OTHER_FALLBACK_URL = - "http://grapheneos.online/generate_204"; - - // DivestOS - private static final String DIVESTOS_HTTPS_URL = - "https://divestos.org/generate_204"; - private static final String DIVESTOS_HTTP_URL = - "http://divestos.org/generate_204"; - - // openSUSE - private static final String OPENSUSE_HTTPS_URL = - "https://conncheck.opensuse.org"; - private static final String OPENSUSE_HTTP_URL = - "http://conncheck.opensuse.org"; - - // Ubuntu - private static final String UBUNTU_HTTPS_URL = - "https://connectivity-check.ubuntu.com"; - private static final String UBUNTU_HTTP_URL = - "http://connectivity-check.ubuntu.com"; - - // Amazon Fire OS - private static final String AMAZON_HTTPS_URL = - "https://fireoscaptiveportal.com/generate_204"; - private static final String AMAZON_HTTP_URL = - "http://fireoscaptiveportal.com/generate_204"; - - // Microsoft Edge - private static final String MICROSOFT_HTTP_URL = - "http://edge-http.microsoft.com/captiveportal/generate_204"; - - // Kuketz, https://www.kuketz-blog.de/android-captive-portal-check-204-http-antwort-von-captiveportal-kuketz-de/ - private static final String KUKETZ_HTTPS_URL = - "https://captiveportal.kuketz.de"; - private static final String KUKETZ_HTTP_URL = - "http://captiveportal.kuketz.de"; - - private static final int DISABLED_CAPTIVE_PORTAL_INTVAL = 0; - private static final int STANDARD_CAPTIVE_PORTAL_HTTP_URL_INTVAL = 1; - private static final int GRAPHENEOS_CAPTIVE_PORTAL_HTTP_URL_INTVAL = 2; - private static final int DIVESTOS_CAPTIVE_PORTAL_HTTP_URL_INTVAL = 3; - private static final int OPENSUSE_CAPTIVE_PORTAL_HTTP_URL_INTVAL = 4; - private static final int UBUNTU_CAPTIVE_PORTAL_HTTP_URL_INTVAL = 5; - private static final int AMAZON_CAPTIVE_PORTAL_HTTP_URL_INTVAL = 6; - private static final int MICROSOFT_CAPTIVE_PORTAL_HTTP_URL_INTVAL = 7; - private static final int KUKETZ_CAPTIVE_PORTAL_HTTP_URL_INTVAL = 8; - - private static final String KEY_CONNECTIVITY_CHECK_SETTINGS = - "connectivity_check_settings"; - - private ListPreference mConnectivityPreference; - - public ConnectivityCheckPreferenceController(Context context) { - super(context, KEY_CONNECTIVITY_CHECK_SETTINGS); - } - - @Override - public int getAvailabilityStatus() { - if (isDisabledByAdmin()) { - return BasePreferenceController.DISABLED_FOR_USER; - } - return BasePreferenceController.AVAILABLE; - } - - @Override - public void displayPreference(PreferenceScreen screen) { - ListPreference captiveList = new ListPreference(screen.getContext()); - captiveList.setKey(KEY_CONNECTIVITY_CHECK_SETTINGS); - captiveList.setOrder(30); - captiveList.setIcon(R.drawable.ic_settings_language); - captiveList.setTitle(R.string.connectivity_check_title); - captiveList.setSummary(R.string.connectivity_check_summary); - captiveList.setEntries(R.array.connectivity_check_entries); - captiveList.setEntryValues(R.array.connectivity_check_values); - - if (mConnectivityPreference == null) { - screen.addPreference(captiveList); - mConnectivityPreference = captiveList; - } - super.displayPreference(screen); - updatePreferenceState(); - } - - @Override - public String getPreferenceKey() { - return KEY_CONNECTIVITY_CHECK_SETTINGS; - } - - private void updatePreferenceState() { - if (Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.CAPTIVE_PORTAL_MODE, Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT) - == Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE) { - mConnectivityPreference.setValueIndex(DISABLED_CAPTIVE_PORTAL_INTVAL); - return; - } - - String pref = Settings.Global.getString( - mContext.getContentResolver(), Settings.Global.CAPTIVE_PORTAL_HTTP_URL); - if (STANDARD_HTTP_URL.equals(pref)) { - mConnectivityPreference.setValueIndex( - STANDARD_CAPTIVE_PORTAL_HTTP_URL_INTVAL); - } else if (GRAPHENEOS_CAPTIVE_PORTAL_HTTP_URL.equals(pref)) { - mConnectivityPreference.setValueIndex( - GRAPHENEOS_CAPTIVE_PORTAL_HTTP_URL_INTVAL); - } else if (DIVESTOS_HTTP_URL.equals(pref)) { - mConnectivityPreference.setValueIndex( - DIVESTOS_CAPTIVE_PORTAL_HTTP_URL_INTVAL); - } else if (OPENSUSE_HTTP_URL.equals(pref)) { - mConnectivityPreference.setValueIndex( - OPENSUSE_CAPTIVE_PORTAL_HTTP_URL_INTVAL); - } else if (UBUNTU_HTTP_URL.equals(pref)) { - mConnectivityPreference.setValueIndex( - UBUNTU_CAPTIVE_PORTAL_HTTP_URL_INTVAL); - } else if (AMAZON_HTTP_URL.equals(pref)) { - mConnectivityPreference.setValueIndex( - AMAZON_CAPTIVE_PORTAL_HTTP_URL_INTVAL); - } else if (MICROSOFT_HTTP_URL.equals(pref)) { - mConnectivityPreference.setValueIndex( - MICROSOFT_CAPTIVE_PORTAL_HTTP_URL_INTVAL); - } else if (KUKETZ_HTTP_URL.equals(pref)) { - mConnectivityPreference.setValueIndex( - KUKETZ_CAPTIVE_PORTAL_HTTP_URL_INTVAL); - } - } - - @Override - public void onResume() { - updatePreferenceState(); - if (mConnectivityPreference != null) { - setCaptivePortalURLs( - mContext.getContentResolver(), - Integer.parseInt(mConnectivityPreference.getValue())); - } - } - - private void setCaptivePortalURLs(ContentResolver cr, int mode) { - switch (mode) { - case STANDARD_CAPTIVE_PORTAL_HTTP_URL_INTVAL: - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, - STANDARD_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, - STANDARD_HTTPS_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, - STANDARD_FALLBACK_URL); - Settings.Global.putString( - cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, - STANDARD_OTHER_FALLBACK_URLS); - Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, - Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); - break; - case GRAPHENEOS_CAPTIVE_PORTAL_HTTP_URL_INTVAL: - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, - GRAPHENEOS_CAPTIVE_PORTAL_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, - GRAPHENEOS_CAPTIVE_PORTAL_HTTPS_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, - GRAPHENEOS_CAPTIVE_PORTAL_FALLBACK_URL); - Settings.Global.putString( - cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, - GRAPHENEOS_CAPTIVE_PORTAL_OTHER_FALLBACK_URL); - Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, - Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); - break; - case DIVESTOS_CAPTIVE_PORTAL_HTTP_URL_INTVAL: - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, - DIVESTOS_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, - DIVESTOS_HTTPS_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, - DIVESTOS_HTTP_URL); - Settings.Global.putString( - cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, - DIVESTOS_HTTP_URL); - Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, - Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); - break; - case OPENSUSE_CAPTIVE_PORTAL_HTTP_URL_INTVAL: - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, - OPENSUSE_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, - OPENSUSE_HTTPS_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, - OPENSUSE_HTTP_URL); - Settings.Global.putString( - cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, - OPENSUSE_HTTP_URL); - Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, - Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); - break; - case UBUNTU_CAPTIVE_PORTAL_HTTP_URL_INTVAL: - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, - UBUNTU_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, - UBUNTU_HTTPS_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, - UBUNTU_HTTP_URL); - Settings.Global.putString( - cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, - UBUNTU_HTTP_URL); - Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, - Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); - break; - case AMAZON_CAPTIVE_PORTAL_HTTP_URL_INTVAL: - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, - AMAZON_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, - AMAZON_HTTPS_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, - AMAZON_HTTP_URL); - Settings.Global.putString( - cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, - AMAZON_HTTP_URL); - Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, - Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); - break; - case MICROSOFT_CAPTIVE_PORTAL_HTTP_URL_INTVAL: - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, - MICROSOFT_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, - MICROSOFT_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, - MICROSOFT_HTTP_URL); - Settings.Global.putString( - cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, - MICROSOFT_HTTP_URL); - Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, - Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); - break; - case KUKETZ_CAPTIVE_PORTAL_HTTP_URL_INTVAL: - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, - KUKETZ_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, - KUKETZ_HTTPS_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, - KUKETZ_HTTP_URL); - Settings.Global.putString( - cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, - KUKETZ_HTTP_URL); - Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, - Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); - break; - default: - // Default URLs as placeholder - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, - STANDARD_HTTP_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, - STANDARD_HTTPS_URL); - Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, - STANDARD_FALLBACK_URL); - Settings.Global.putString( - cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, - STANDARD_OTHER_FALLBACK_URLS); - Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, - Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE); - } - } - - @Override - public boolean onPreferenceChange(Preference preference, Object value) { - final String key = preference.getKey(); - if (KEY_CONNECTIVITY_CHECK_SETTINGS.equals(key)) { - setCaptivePortalURLs(mContext.getContentResolver(), - Integer.parseInt((String)value)); - return true; - } else { - return false; - } - } - - private EnforcedAdmin getEnforcedAdmin() { - return RestrictedLockUtilsInternal.checkIfRestrictionEnforced( - mContext, UserManager.DISALLOW_CONFIG_PRIVATE_DNS, - UserHandle.myUserId()); - } - - private boolean isDisabledByAdmin() { return getEnforcedAdmin() != null; } -} diff --git a/LeOS/DnsResolver_hosts_cache.cpp b/LeOS/DnsResolver_hosts_cache.cpp deleted file mode 100644 index 09ed4f95..00000000 --- a/LeOS/DnsResolver_hosts_cache.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/* - * Copyright (C) 2020 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "hostent.h" -#include "resolv_private.h" - -constexpr int MAXALIASES = 35; -constexpr int MAXADDRS = 35; - -#define MAX_ADDRLEN (INET6_ADDRSTRLEN - (1 + 5)) -#define MAX_HOSTLEN MAXHOSTNAMELEN - -#define ESTIMATED_LINELEN 32 -#define HCFILE_ALLOC_SIZE 256 - -/* From sethostent.c */ -#define ALIGNBYTES (sizeof(uintptr_t) - 1) -#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES) - -/* - * Host cache entry for hcfile.c_data. - * Offsets are into hcfile.h_data. - * Strings are *not* terminated by NULL, but by whitespace (isspace) or '#'. - * Use hstr* functions with these. - */ -struct hcent -{ - uint32_t addr; - uint32_t name; -}; - -/* - * Overall host cache file state. - */ -struct hcfile -{ - int h_fd; - struct stat h_st; - char* h_data; - - uint32_t c_alloc; - uint32_t c_len; - struct hcent* c_data; -}; -static struct hcfile hcfile; -static pthread_mutex_t hclock = PTHREAD_MUTEX_INITIALIZER; - -static size_t hstrlen(const char *s) -{ - const char *p = s; - while (*p && *p != '#' && !isspace(*p)) - ++p; - return p - s; -} - -static int hstrcmp(const char *a, const char *b) -{ - size_t alen = hstrlen(a); - size_t blen = hstrlen(b); - int res = strncmp(a, b, MIN(alen, blen)); - if (res == 0) - res = alen - blen; - return res; -} - -static char *hstrcpy(char *dest, const char *src) -{ - size_t len = hstrlen(src); - memcpy(dest, src, len); - dest[len] = '\0'; - return dest; -} - -static char *hstrdup(const char *s) -{ - size_t len = hstrlen(s); - char *dest = (char *)malloc(len + 1); - if (!dest) - return NULL; - memcpy(dest, s, len); - dest[len] = '\0'; - return dest; -} - -static int cmp_hcent_name(const void *a, const void *b) -{ - struct hcent *ea = (struct hcent *)a; - const char *na = hcfile.h_data + ea->name; - struct hcent *eb = (struct hcent *)b; - const char *nb = hcfile.h_data + eb->name; - - return hstrcmp(na, nb); -} - -static struct hcent *_hcfindname(const char *name) -{ - size_t first, last, mid; - struct hcent *cur = NULL; - int cmp; - - if (hcfile.c_len == 0) - return NULL; - - first = 0; - last = hcfile.c_len - 1; - mid = (first + last) / 2; - while (first <= last) { - cur = hcfile.c_data + mid; - cmp = hstrcmp(hcfile.h_data + cur->name, name); - if (cmp == 0) - goto found; - if (cmp < 0) - first = mid + 1; - else { - if (mid > 0) - last = mid - 1; - else - return NULL; - } - mid = (first + last) / 2; - } - return NULL; - -found: - while (cur > hcfile.c_data) { - struct hcent *prev = cur - 1; - cmp = cmp_hcent_name(cur, prev); - if (cmp) - break; - cur = prev; - } - - return cur; -} - -/* - * Find next name on line, if any. - * - * Assumes that line is terminated by LF. - */ -static const char *_hcnextname(const char *name) -{ - while (!isspace(*name)) { - if (*name == '#') - return NULL; - ++name; - } - while (isspace(*name)) { - if (*name == '\n') - return NULL; - ++name; - } - if (*name == '#') - return NULL; - return name; -} - -static int _hcfilemmap(void) -{ - struct stat st; - int h_fd; - char *h_addr; - const char *p, *pend; - uint32_t c_alloc; - - h_fd = open(_PATH_HOSTS, O_CLOEXEC); - if (h_fd < 0) - return -1; - if (flock(h_fd, LOCK_EX) != 0) { - close(h_fd); - return -1; - } - - if (hcfile.h_data) { - memset(&st, 0, sizeof(st)); - if (fstat(h_fd, &st) == 0) { - if (st.st_size == hcfile.h_st.st_size && - st.st_mtime == hcfile.h_st.st_mtime) { - flock(h_fd, LOCK_UN); - close(h_fd); - return 0; - } - } - free(hcfile.c_data); - munmap(hcfile.h_data, hcfile.h_st.st_size); - close(hcfile.h_fd); - memset(&hcfile, 0, sizeof(struct hcfile)); - } - - if (fstat(h_fd, &st) != 0) { - flock(h_fd, LOCK_UN); - close(h_fd); - return -1; - } - h_addr = (char*)mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, h_fd, 0); - if (h_addr == MAP_FAILED) { - flock(h_fd, LOCK_UN); - close(h_fd); - return -1; - } - - hcfile.h_fd = h_fd; - hcfile.h_st = st; - hcfile.h_data = h_addr; - - c_alloc = 0; - /* - * Do an initial allocation if the file is "large". Estimate - * 32 bytes per line and define "large" as more than half of - * the alloc growth size (256 entries). - */ - if (st.st_size >= ESTIMATED_LINELEN * HCFILE_ALLOC_SIZE / 2) { - c_alloc = st.st_size / ESTIMATED_LINELEN; - hcfile.c_data = (struct hcent*)malloc(c_alloc * sizeof(struct hcent)); - if (!hcfile.c_data) { - goto oom; - } - } - - p = (const char *)h_addr; - pend = p + st.st_size; - while (p < pend) { - const char *eol, *addr, *name; - size_t len; - addr = p; - eol = (const char*)memchr(p, '\n', pend - p); - if (!eol) - break; - p = eol + 1; - if (*addr == '#' || *addr == '\n') - continue; - len = hstrlen(addr); - if (len > MAX_ADDRLEN) - continue; - name = addr + len; - while (name < eol && isspace(*name)) - ++name; - while (name < eol) { - len = hstrlen(name); - if (len == 0) - break; - if (len < MAX_HOSTLEN) { - struct hcent *ent; - if (c_alloc <= hcfile.c_len) { - struct hcent *c_data; - c_alloc += HCFILE_ALLOC_SIZE; - c_data = (struct hcent*)realloc(hcfile.c_data, c_alloc * sizeof(struct hcent)); - if (!c_data) { - goto oom; - } - hcfile.c_data = c_data; - } - ent = hcfile.c_data + hcfile.c_len; - ent->addr = addr - h_addr; - ent->name = name - h_addr; - ++hcfile.c_len; - } - name += len; - while (name < eol && isspace(*name)) - ++name; - } - } - - qsort(hcfile.c_data, hcfile.c_len, - sizeof(struct hcent), cmp_hcent_name); - - flock(h_fd, LOCK_UN); - - return 0; - -oom: - free(hcfile.c_data); - munmap(hcfile.h_data, hcfile.h_st.st_size); - flock(hcfile.h_fd, LOCK_UN); - close(hcfile.h_fd); - memset(&hcfile, 0, sizeof(struct hcfile)); - return -1; -} - -/* - * Caching version of getaddrinfo. - * - * If we find the requested host name in the cache, use getaddrinfo to - * populate the result for each address we find. - * - * Note glibc and bionic differ in the handling of ai_canonname. POSIX - * says that ai_canonname is only populated in the first result entry. - * glibc does this. bionic populates ai_canonname in all result entries. - * We choose the POSIX/glibc way here. - */ -int hc_getaddrinfo(const char *name, const struct addrinfo* hints, struct addrinfo** result) -{ - int ret = 0; - struct hcent *ent, *cur; - struct addrinfo *ai; - struct addrinfo rhints; - struct addrinfo *last; - int canonname = 0; - int cmp; - - if (getenv("ANDROID_HOSTS_CACHE_DISABLE") != NULL) - return EAI_SYSTEM; - - if (!name) - return EAI_SYSTEM; - - pthread_mutex_lock(&hclock); - - if (_hcfilemmap() != 0) { - ret = EAI_SYSTEM; - goto out; - } - ent = _hcfindname(name); - if (!ent) { - ret = EAI_NONAME; - goto out; - } - - if (hints) { - canonname = (hints->ai_flags & AI_CANONNAME); - memcpy(&rhints, hints, sizeof(rhints)); - rhints.ai_flags &= ~AI_CANONNAME; - } - else { - memset(&rhints, 0, sizeof(rhints)); - } - rhints.ai_flags |= AI_NUMERICHOST; - - last = NULL; - cur = ent; - do { - char addrstr[MAX_ADDRLEN]; - struct addrinfo *res; - - hstrcpy(addrstr, hcfile.h_data + cur->addr); - - if (getaddrinfo_numeric(addrstr, nullptr, rhints, &res) == 0) { - if (!last) - (*result)->ai_next = res; - else - last->ai_next = res; - last = res; - while (last->ai_next) - last = last->ai_next; - } - - if(cur + 1 >= hcfile.c_data + hcfile.c_len) - break; - cmp = cmp_hcent_name(cur, cur + 1); - cur = cur + 1; - } - while (!cmp); - - if (last == NULL) { - /* This check is equivalent to (*result)->ai_next == NULL */ - ret = EAI_NODATA; - goto out; - } - - if (canonname) { - ai = (*result)->ai_next; - free(ai->ai_canonname); - ai->ai_canonname = hstrdup(hcfile.h_data + ent->name); - } - -out: - pthread_mutex_unlock(&hclock); - return ret; -} - -/* - * Caching version of gethtbyname. - * - * Note glibc and bionic differ in the handling of aliases. glibc returns - * all aliases for all entries, regardless of whether they match h_addrtype. - * bionic returns only the aliases for the first hosts entry. We return all - * aliases for all IPv4 entries. - * - * Additionally, if an alias is IPv6 and the primary name for an alias also - * has an IPv4 entry, glibc will return the IPv4 address(es), but bionic - * will not. Neither do we. - */ -int hc_gethtbyname(const char *host, int af, struct getnamaddr *info) -{ - int ret = NETDB_SUCCESS; - struct hcent *ent, *cur; - int cmp; - size_t addrlen; - unsigned int naliases = 0; - char *aliases[MAXALIASES]; - unsigned int naddrs = 0; - char *addr_ptrs[MAXADDRS]; - unsigned int n; - - if (getenv("ANDROID_HOSTS_CACHE_DISABLE") != NULL) - return NETDB_INTERNAL; - - switch (af) { - case AF_INET: addrlen = NS_INADDRSZ; break; - case AF_INET6: addrlen = NS_IN6ADDRSZ; break; - default: - return NETDB_INTERNAL; - } - - pthread_mutex_lock(&hclock); - - if (_hcfilemmap() != 0) { - ret = NETDB_INTERNAL; - goto out; - } - - ent = _hcfindname(host); - if (!ent) { - ret = HOST_NOT_FOUND; - goto out; - } - - cur = ent; - do { - char addr[16]; - char addrstr[MAX_ADDRLEN]; - char namestr[MAX_HOSTLEN]; - const char *name; - - hstrcpy(addrstr, hcfile.h_data + cur->addr); - if (inet_pton(af, addrstr, &addr) == 1) { -/* char *aligned; - First match is considered the official hostname */ - if (naddrs == 0) { - hstrcpy(namestr, hcfile.h_data + cur->name); - HENT_SCOPY(info->hp->h_name, namestr, info->buf, info->buflen); - } - for (name = hcfile.h_data + cur->name; name; name = _hcnextname(name)) { - if (!hstrcmp(name, host)) - continue; - hstrcpy(namestr, name); - HENT_SCOPY(aliases[naliases], namestr, info->buf, info->buflen); - ++naliases; - if (naliases >= MAXALIASES) - goto nospc; - } -/* aligned = (char *)ALIGN(info->buf); - if (info->buf != aligned) { - if ((ptrdiff_t)info->buflen < (aligned - info->buf)) - goto nospc; - info->buflen -= (aligned - info->buf); - info->buf = aligned; - } */ - HENT_COPY(addr_ptrs[naddrs], addr, addrlen, info->buf, info->buflen); - ++naddrs; - if (naddrs >= MAXADDRS) - goto nospc; - } - - if(cur + 1 >= hcfile.c_data + hcfile.c_len) - break; - cmp = cmp_hcent_name(cur, cur + 1); - cur = cur + 1; - } - while (!cmp); - - if (naddrs == 0) { - ret = HOST_NOT_FOUND; - goto out; - } - - addr_ptrs[naddrs++] = NULL; - aliases[naliases++] = NULL; - - /* hp->h_name already populated */ - HENT_ARRAY(info->hp->h_aliases, naliases, info->buf, info->buflen); - for (n = 0; n < naliases; ++n) { - info->hp->h_aliases[n] = aliases[n]; - } - info->hp->h_addrtype = af; - info->hp->h_length = addrlen; - HENT_ARRAY(info->hp->h_addr_list, naddrs, info->buf, info->buflen); - for (n = 0; n < naddrs; ++n) { - info->hp->h_addr_list[n] = addr_ptrs[n]; - } - -out: - pthread_mutex_unlock(&hclock); - return ret; - -nospc: - ret = NETDB_INTERNAL; - goto out; -} diff --git a/LeOS/DnsResolver_hosts_cache.h b/LeOS/DnsResolver_hosts_cache.h deleted file mode 100644 index 75637b13..00000000 --- a/LeOS/DnsResolver_hosts_cache.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2020 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NETD_RESOLV_HOSTS_CACHE_H -#define NETD_RESOLV_HOSTS_CACHE_H - -struct getnamaddr; - -int hc_getaddrinfo(const char* name, const struct addrinfo* hints, - struct addrinfo** result); - -int hc_gethtbyname(const char *host, int af, struct getnamaddr *info); - -#endif diff --git a/LeOS/HostsPreferenceController.java b/LeOS/HostsPreferenceController.java deleted file mode 100644 index fd65c458..00000000 --- a/LeOS/HostsPreferenceController.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.settings.security; - -import android.content.Context; - -import android.os.UserHandle; -import android.os.UserManager; -import android.os.SystemProperties; - -import android.provider.Settings; - -import androidx.preference.Preference; -import androidx.preference.PreferenceCategory; -import androidx.preference.PreferenceGroup; -import androidx.preference.PreferenceScreen; -import androidx.preference.TwoStatePreference; -import androidx.preference.SwitchPreference; - -import com.android.internal.widget.LockPatternUtils; -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settingslib.core.AbstractPreferenceController; -import com.android.settingslib.core.lifecycle.events.OnResume; - -public class HostsPreferenceController extends AbstractPreferenceController - implements PreferenceControllerMixin, OnResume, Preference.OnPreferenceChangeListener { - - private static final String SYS_KEY_HOSTS_DISABLE = "persist.security.hosts_disable"; - private static final String PREF_KEY_HOSTS_DISABLE = "hosts_disable"; - private static final String PREF_KEY_SECURITY_CATEGORY = "security_category"; - - private PreferenceCategory mSecurityCategory; - private SwitchPreference mHostsDisable; - private boolean mIsAdmin; - private UserManager mUm; - - public HostsPreferenceController(Context context) { - super(context); - mUm = UserManager.get(context); - } - - @Override - public void displayPreference(PreferenceScreen screen) { - super.displayPreference(screen); - mSecurityCategory = screen.findPreference(PREF_KEY_SECURITY_CATEGORY); - updatePreferenceState(); - } - - @Override - public boolean isAvailable() { - mIsAdmin = mUm.isAdminUser(); - return mIsAdmin; - } - - @Override - public String getPreferenceKey() { - return PREF_KEY_HOSTS_DISABLE; - } - - // TODO: should we use onCreatePreferences() instead? - private void updatePreferenceState() { - if (mSecurityCategory == null) { - return; - } - - if (mIsAdmin) { - mHostsDisable = (SwitchPreference) mSecurityCategory.findPreference(PREF_KEY_HOSTS_DISABLE); - mHostsDisable.setChecked(SystemProperties.getInt(SYS_KEY_HOSTS_DISABLE, 0) == 1); - } else { - mSecurityCategory.removePreference(mSecurityCategory.findPreference(PREF_KEY_HOSTS_DISABLE)); - } - } - - @Override - public void onResume() { - updatePreferenceState(); - if (mHostsDisable != null) { - boolean mode = mHostsDisable.isChecked(); - SystemProperties.set(SYS_KEY_HOSTS_DISABLE, mode ? "1" : "0"); - } - } - @Override - public boolean onPreferenceChange(Preference preference, Object value) { - final String key = preference.getKey(); - if (PREF_KEY_HOSTS_DISABLE.equals(key)) { - final boolean mode = !mHostsDisable.isChecked(); - SystemProperties.set(SYS_KEY_HOSTS_DISABLE, mode ? "1" : "0"); - } - return true; - } -} diff --git a/LeOS/a64N.sh b/LeOS/a64N.sh deleted file mode 100644 index 543a0bc5..00000000 --- a/LeOS/a64N.sh +++ /dev/null @@ -1,24 +0,0 @@ -START=`date +%s` -export RELAX_USES_LIBRARY_CHECK=true -export USE_CCACHE=1 -export CCACHE_SIZE=100G -echo "ready to build" - -cp update.sh prebuilts/prebuiltapks/foss_nano -cd prebuilts/prebuiltapks/foss_nano -bash update.sh -cd ../../.. - -source build/envsetup.sh -export WITHOUT_CHECK_API=true - -lunch lineage_a64_bvN-userdebug - -make installclean -make -j4 systemimage -make vndk-test-sepolicy -cp $OUT/system.img images/LeOS-19.1-VNDK-a64-bvN.img - - - - diff --git a/LeOS/a64S.sh b/LeOS/a64S.sh deleted file mode 100644 index 6f614957..00000000 --- a/LeOS/a64S.sh +++ /dev/null @@ -1,27 +0,0 @@ -START=`date +%s` -export RELAX_USES_LIBRARY_CHECK=true -export USE_CCACHE=1 -export CCACHE_SIZE=100G -echo "ready to build" - -cp updateS.sh prebuilts/prebuiltapks/foss_nano -cd prebuilts/prebuiltapks/foss_nano -bash updateS.sh -cd ../../.. - -source build/envsetup.sh -export WITHOUT_CHECK_API=true -export WITH_SU=true - -lunch lineage_a64_bvS-userdebug - -make installclean -make -j4 systemimage -make vndk-test-sepolicy - -############# sas-creator call ############## -cd sas-creator/ -sudo bash lite-adapterSa64.sh 32 system.img -###################################### - - diff --git a/LeOS/all.sh b/LeOS/all.sh deleted file mode 100644 index 5e78a3e7..00000000 --- a/LeOS/all.sh +++ /dev/null @@ -1,6 +0,0 @@ - -echo 'Start building' -bash arm64S.sh -bash a64S.sh -bash arm64N.sh -bash a64.sh diff --git a/LeOS/arm64N.sh b/LeOS/arm64N.sh deleted file mode 100644 index 69d0cdcf..00000000 --- a/LeOS/arm64N.sh +++ /dev/null @@ -1,24 +0,0 @@ -START=`date +%s` -export RELAX_USES_LIBRARY_CHECK=true -export USE_CCACHE=1 -export CCACHE_SIZE=50G -echo "ready to build" - -cp update.sh prebuilts/prebuiltapks/foss_nano -cd prebuilts/prebuiltapks/foss_nano -bash update.sh -cd ../../.. - - -source build/envsetup.sh -export WITHOUT_CHECK_API=true - -lunch lineage_arm64_bvN-userdebug - -make installclean -make -j4 systemimage -make vndk-test-sepolicy -cp $OUT/system.img images/LeOS-19.1-VNDK-arm64-bvN.img - - - diff --git a/LeOS/arm64S.sh b/LeOS/arm64S.sh deleted file mode 100644 index 99379f2a..00000000 --- a/LeOS/arm64S.sh +++ /dev/null @@ -1,27 +0,0 @@ -START=`date +%s` -export RELAX_USES_LIBRARY_CHECK=true -export USE_CCACHE=1 -export CCACHE_SIZE=100G -echo "ready to build" - -cp updateS.sh prebuilts/prebuiltapks/foss_nano -cd prebuilts/prebuiltapks/foss_nano -bash updateS.sh -cd ../../.. - -source build/envsetup.sh -export WITHOUT_CHECK_API=true -export WITH_SU=true - -lunch lineage_arm64_bvS-userdebug - -make installclean -make -j4 systemimage -make vndk-test-sepolicy - -############# sas-creator call ############## -cd sas-creator -sudo bash lite-adapterS.sh 64 system.img -###################################### - - diff --git a/LeOS/build-u.sh b/LeOS/build-u.sh index 58ac7da9..308164d4 100644 --- a/LeOS/build-u.sh +++ b/LeOS/build-u.sh @@ -1,5 +1,7 @@ #!/bin/bash +MONTH="date +%B" + echo echo "--------------------------------------" echo " LeOS-U Buildbot " @@ -8,10 +10,10 @@ echo " harvey186 " echo "--------------------------------------" echo -git clone http://62.178.96.192:3000/JoJo/LeOS-GSI.git -b LeOS-U -cd LeOS-GSI git clone https://github.com/ponces/treble_aosp -b android-14.0 +git clone https://github.com/ponces/vendor_ponces.git -b android-14.0 vendor/ponces + set -e initRepos() { @@ -21,6 +23,7 @@ initRepos() { echo echo "--> Preparing local manifest" mkdir -p .repo/local_manifests + cp treble_aosp/build/manifest.xml .repo/local_manifests/aosp.xml cp LeOS/leos.xml .repo/local_manifests/leos.xml cp LeOS/removeAOSP.xml .repo/local_manifests/remove.xml echo @@ -33,5 +36,148 @@ syncRepos() { echo } +applyPatches() { + echo "--> Applying TrebleDroid patches" + bash treble_aosp/patch.sh treble_aosp trebledroid + echo + + echo "--> Applying ponces personal patches" + rm treble_aosp/patches/personal/platform_frameworks_base/0001-gmscompat-Change-attestation-and-instrumentation-to-.patch + rm treble_aosp/patches/personal/platform_frameworks_base/0002-gmscompat-Spoof-Pixel-XL-for-Google-Photos.patch + rm treble_aosp/patches/personal/platform_frameworks_base/0007-permissions-Pre-grant-google-restore-permissions.patch + rm -R treble_aosp/patches/personal/platform_frameworks_base/0008-feat-Add-Lockscreen-Weather-with-OmniJaws-1-2.patch + rm -R treble_aosp/patches/personal/platform_packages_apps_Settings/0001-feat-Add-Lockscreen-Weather-with-OmniJaws-2-2.patch + rm treble_aosp/patches/personal/platform_build/0001-Remove-su-from-vanilla-builds.patch + bash treble_aosp/patch.sh treble_aosp personal + echo + + echo "--> Applying LeOS patches" + mv patches/leos treble_aosp/patches/leos + bash treble_aosp/patch.sh treble_aosp leos + cp LeOS/instrumentation_test_list.mk plattform_testing/build/tasks/tests/ + cp LeOS/platform_test_list.mk plattform_testing/build/tasks/tests/ + echo + + echo "--> Generating makefiles" + cd device/phh/treble + cp treble_aosp/build/aosp.mk device/phh/treble/ + bash generate.sh aosp + cd ../../.. + echo +} + +setupEnv() { + echo "--> Setting up build environment" + source build/envsetup.sh &>/dev/null + mkdir -p $BD + echo +} + +buildTrebleApp() { + echo "--> Building treble_app" + cd treble_app + bash build.sh release + cp TrebleApp.apk ../vendor/hardware_overlay/TrebleApp/app.apk + cd .. + echo +} + +buildVanillaVariant() { + echo "--> Building treble_arm64_bvS" + export WITHOUT_CHECK_API=true + export USE_CCACHE=1 + export CCACHE_SIZE=50G + export WITH_SU=true + lunch leos_arm64_bvS-userdebug + #make installclean + make -j12 RELAX_USES_LIBRARY_CHECK=true systemimage + echo + echo "--> Building treble_a64_bvS" + export WITHOUT_CHECK_API=true + export USE_CCACHE=1 + export CCACHE_SIZE=50G + export WITH_SU=true + lunch leos_a64_bvS-userdebug + #make installclean + make -j12 RELAX_USES_LIBRARY_CHECK=true systemimage + + echo "--> Building LeOS-U-VNDKLITE-arm64-bvS.img" + cd treble_adapter + sudo bash lite-adapter.sh 64 ../out/target/product/leos_arm64_ab/system.img + mv s.img LeOS-U-VNDKLITE-arm64-bvS.img + sudo rm -rf d tmp + + echo "--> Building LeOS-U-VNDKLITE-arm64-bvN" + sudo bash lite-adapterN.sh 64 ../out/target/product/leos_arm64_ab/system.img + mv s.img LeOS-U-VNDKLITE-arm64-bvN.img + sudo rm -rf d tmp + cd .. + echo + + echo "--> Building LeOS-U-VNDKLITE-a64-bvS.img" + cd treble_adapter + sudo bash lite-adapterSa64.sh 32 ../out/target/product/leos_a64_ab/system.img + mv s.img LeOS-U-VNDKLITE-a64-bvS.img + sudo rm -rf d tmp + + echo "--> Building LeOS-U-VNDKLITE-a64-bvN" + sudo bash lite-adapterNa64.sh 32 ../out/target/product/leos_a64_ab/system.img + mv s.img LeOS-U-VNDKLITE-a64-bvN.img + sudo rm -rf d tmp + cd .. + echo + + + cd prebuilts/prebuiltapks/foss_nano/ + bash update.sh + cd ../../.. + + echo "--> Building treble_arm64_bvN" + export WITHOUT_CHECK_API=true + export USE_CCACHE=1 + export CCACHE_SIZE=50G + export WITH_SU=true + lunch leos_arm64_bvN-userdebug + #make installclean + make -j12 RELAX_USES_LIBRARY_CHECK=true systemimage + echo + echo "--> Building treble_a64_bvN" + export WITHOUT_CHECK_API=true + export USE_CCACHE=1 + export CCACHE_SIZE=50G + export WITH_SU=true + lunch leos_a64_bvN-userdebug + #make installclean + make -j12 RELAX_USES_LIBRARY_CHECK=true systemimage + +} + +generatePackages() { + echo "--> Generating packages" + cp out/target/product/leos_arm64_ab/system.img treble_adapter/LeOS-U-VNDK-arm64_bvN.img + cp out/target/product/leos_a64_ab/system.img treble_adapter/LeOS-U-VNDK-a64-bvN.img + cd treble_adapter + xz -vT0 *.img + cp *.img.xz /media/ich/exSSD2/leos-cloud/LeOS-Files/LeOS-U/$MONTH/ + echo +} + +echo "READY" +START=$(date +%s) + +initRepos +syncRepos +applyPatches +setupEnv +buildTrebleApp +buildVanillaVariant +generatePackages + +END=$(date +%s) +ELAPSEDM=$(($(($END-$START))/60)) +ELAPSEDS=$(($(($END-$START))-$ELAPSEDM*60)) + +echo "--> Buildbot completed in $ELAPSEDM minutes and $ELAPSEDS seconds" +echo diff --git a/LeOS/build.sh b/LeOS/build.sh deleted file mode 100644 index d1b1134e..00000000 --- a/LeOS/build.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash -git clone https://github.com/AndyCGYan/lineage_build_unified lineage_build_unified -b lineage-19.1 -git clone https://github.com/AndyCGYan/lineage_patches_unified lineage_patches_unified -b lineage-19.1 - -echo 'patch build bot and run it' -cp LeOS/bot.patch lineage_build_unified/ -cd lineage_build_unified -git apply bot.patch -cd .. -bash lineage_build_unified/buildbot_unified.sh treble 64B - -mkdir images - -echo 'Bootanimation' -cp LeOS/android-logo-mask1a.png frameworks/base/core/res/assets/images/android-logo-mask.png -cp LeOS/android-logo-shine.png frameworks/base/core/res/assets/images/android-logo-shine.png -rm device/phh/treble/bootanimation.zip -rm -R vendor/lineage/bootanimation/ -rm device/phh/treble/phh.mk - - -echo 'background' -cp LeOS/default_wallpaper.png frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.png -cp LeOS/default_wallpaper.png frameworks/base/core/res/res/drawable-sw600dp-nodpi/default_wallpaper.png -cp LeOS/default_wallpaper.png frameworks/base/core/res/res/drawable-sw720dp-nodpi/default_wallpaper.png -cp LeOS/default_wallpaper.png frameworks/base/tests/HwAccelerationTest/res/drawable/default_wallpaper.png -rm -R vendor/lineage/overlay/common/frameworks/base/core/res/res/drawable* - -echo 'Fonts' -cp LeOS/Roboto-Regular.ttf external/roboto-fonts/ -cp LeOS/RobotoStatic-Regular.ttf external/roboto-fonts/ - -echo 'EasterEgg' -rm -R frameworks/base/packages/EasterEgg - -echo 'remove apps' -rm -R packages/apps/AudioFX -rm -R packages/apps/Eleven -rm -R packages/apps/Camera2 -rm -R packages/apps/Contacts -rm -R packages/apps/DeskClock -rm -R packages/apps/Etar -rm -R packages/apps/Dialer -rm -R packages/apps/ExactCalculator -rm -R packages/apps/Gallery2 -rm -R packages/apps/FlipFlap -rm -R packages/apps/Messaging -rm -R packages/apps/Jelly -rm -R vendor/partner_gms/ -rm -R packages/apps/UniversalMediaPlayer -rm -R packages/apps/HTMLViewer -rm -R packages/apps/Recorder -rm -R packages/apps/ImsServiceEntitlement/src/com/android/imsserviceentitlement/fcm - -echo 'LeOS apps' -tar -xf LeOS/prebuiltapks.tar.xz -C prebuilts/ - -echo 'webview' -tar -xf LeOS/bromite-webview.tar.xz -C external -cd external/bromite-webview -bash update.sh -cd ../.. - -echo 'a-gps' -cd vendor/hardware_overlay -grep -RiIl 'supl.three.com' | xargs sed -i 's/supl.three.com/supl.three.com/g' -cd ../.. - -echo 'hosts' -cp LeOS/hosts system/core/rootdir/etc/ - -echo 'firebase mods' -cp LeOS/firebase-messaging-21.0.1.aar external/firebase-messaging/libs/ -cp LeOS/play-services-cloud-messaging-16.0.0.aar external/firebase-messaging/libs/ - -echo 'overlays' -tar -xf LeOS/overlay.tar.xz -C vendor -cp LeOS/vendor_hardware-overlay.patch vendor/hardware_overlay -cd vendor/hardware_overlay -git apply *.patch -cd ../.. - -echo 'encoder' -mkdir vendor/LeOS -tar -xf LeOS/encoder.tar.xz -C vendor/LeOS - -echo 'sas-creator' -tar -xf LeOS/sas-creator.tar.xz -C . - -echo 'scripts' -tar -xf LeOS/scripts.tar.xz -C . -cp LeOS/leos.mk device/phh/treble - -cp LeOS/leos.mk device/phh/treble - -echo 'Patches' -tar -xf LeOS/patches.tar.xz -bash patches/apply.sh leos - -cp LeOS/platform_testing.patch platform_testing/ -cd platform_testing/ -git apply *.patch -cd .. - -echo 'generate Scripts' -cd device/phh/treble -bash generate.sh lineage -cd ../../../ - -echo 'Texte' -cp LeOS/texte.sh . -bash texte.sh -rm texte.sh - -export RELAX_USES_LIBRARY_CHECK=true - -bash arm64S.sh - -mv sas-creator/*.img images - - - - - - - - - - - - - - - - - - - - - - diff --git a/LeOS/hosts_cache.c b/LeOS/hosts_cache.c deleted file mode 100644 index fc6370d0..00000000 --- a/LeOS/hosts_cache.c +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "hostent.h" -#include "resolv_private.h" - -#define MAX_ADDRLEN (INET6_ADDRSTRLEN - (1 + 5)) -#define MAX_HOSTLEN MAXHOSTNAMELEN - -#define ESTIMATED_LINELEN 32 -#define HCFILE_ALLOC_SIZE 256 - -/* - * Host cache entry for hcfile.c_data. - * Offsets are into hcfile.h_data. - * Strings are *not* terminated by NULL, but by whitespace (isspace) or '#'. - * Use hstr* functions with these. - */ -struct hcent -{ - uint32_t addr; - uint32_t name; -}; - -/* - * Overall host cache file state. - */ -struct hcfile -{ - int h_fd; - struct stat h_st; - char *h_data; - - uint32_t c_alloc; - uint32_t c_len; - struct hcent *c_data; -}; -static struct hcfile hcfile; -static pthread_mutex_t hclock = PTHREAD_MUTEX_INITIALIZER; - -static size_t hstrlen(const char *s) -{ - const char *p = s; - while (*p && *p != '#' && !isspace(*p)) - ++p; - return p - s; -} - -static int hstrcmp(const char *a, const char *b) -{ - size_t alen = hstrlen(a); - size_t blen = hstrlen(b); - int res = strncmp(a, b, MIN(alen, blen)); - if (res == 0) - res = alen - blen; - return res; -} - -static char *hstrcpy(char *dest, const char *src) -{ - size_t len = hstrlen(src); - memcpy(dest, src, len); - dest[len] = '\0'; - return dest; -} - -static char *hstrdup(const char *s) -{ - size_t len = hstrlen(s); - char *dest = (char *)malloc(len + 1); - if (!dest) - return NULL; - memcpy(dest, s, len); - dest[len] = '\0'; - return dest; -} - -static int cmp_hcent_name(const void *a, const void *b) -{ - struct hcent *ea = (struct hcent *)a; - const char *na = hcfile.h_data + ea->name; - struct hcent *eb = (struct hcent *)b; - const char *nb = hcfile.h_data + eb->name; - - return hstrcmp(na, nb); -} - -static struct hcent *_hcfindname_exact(const char *name) -{ - size_t first, last, mid; - struct hcent *cur = NULL; - int cmp; - - if (hcfile.c_len == 0) - return NULL; - - first = 0; - last = hcfile.c_len - 1; - mid = (first + last) / 2; - while (first <= last) { - cur = hcfile.c_data + mid; - cmp = hstrcmp(hcfile.h_data + cur->name, name); - if (cmp == 0) - goto found; - if (cmp < 0) - first = mid + 1; - else { - if (mid > 0) - last = mid - 1; - else - return NULL; - } - mid = (first + last) / 2; - } - return NULL; - -found: - while (cur > hcfile.c_data) { - struct hcent *prev = cur - 1; - cmp = cmp_hcent_name(cur, prev); - if (cmp) - break; - cur = prev; - } - - return cur; -} - -static struct hcent *_hcfindname(const char *name) -{ - struct hcent *ent; - char namebuf[MAX_HOSTLEN]; - char *p; - char *dot; - - ent = _hcfindname_exact(name); - if (!ent && strlen(name) < sizeof(namebuf)) { - strcpy(namebuf, name); - p = namebuf; - do { - dot = strchr(p, '.'); - if (!dot) - break; - if (dot > p) { - *(dot - 1) = '*'; - ent = _hcfindname_exact(dot - 1); - } - p = dot + 1; - } - while (!ent); - } - - return ent; -} - -/* - * Find next name on line, if any. - * - * Assumes that line is terminated by LF. - */ -static const char *_hcnextname(const char *name) -{ - while (!isspace(*name)) { - if (*name == '#') - return NULL; - ++name; - } - while (isspace(*name)) { - if (*name == '\n') - return NULL; - ++name; - } - if (*name == '#') - return NULL; - return name; -} - -static int _hcfilemmap(void) -{ - struct stat st; - int h_fd; - char *h_addr; - const char *p, *pend; - uint32_t c_alloc; - - h_fd = open(_PATH_HOSTS, O_RDONLY); - if (h_fd < 0) - return -1; - if (flock(h_fd, LOCK_EX) != 0) { - close(h_fd); - return -1; - } - - if (hcfile.h_data) { - memset(&st, 0, sizeof(st)); - if (fstat(h_fd, &st) == 0) { - if (st.st_size == hcfile.h_st.st_size && - st.st_mtime == hcfile.h_st.st_mtime) { - flock(h_fd, LOCK_UN); - close(h_fd); - return 0; - } - } - free(hcfile.c_data); - munmap(hcfile.h_data, hcfile.h_st.st_size); - close(hcfile.h_fd); - memset(&hcfile, 0, sizeof(struct hcfile)); - } - - if (fstat(h_fd, &st) != 0) { - flock(h_fd, LOCK_UN); - close(h_fd); - return -1; - } - h_addr = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, h_fd, 0); - if (h_addr == MAP_FAILED) { - flock(h_fd, LOCK_UN); - close(h_fd); - return -1; - } - - hcfile.h_fd = h_fd; - hcfile.h_st = st; - hcfile.h_data = h_addr; - - c_alloc = 0; - /* - * Do an initial allocation if the file is "large". Estimate - * 32 bytes per line and define "large" as more than half of - * the alloc growth size (256 entries). - */ - if (st.st_size >= ESTIMATED_LINELEN * HCFILE_ALLOC_SIZE / 2) { - c_alloc = st.st_size / ESTIMATED_LINELEN; - hcfile.c_data = malloc(c_alloc * sizeof(struct hcent)); - if (!hcfile.c_data) { - goto oom; - } - } - - p = (const char *)h_addr; - pend = p + st.st_size; - while (p < pend) { - const char *eol, *addr, *name; - size_t len; - addr = p; - eol = memchr(p, '\n', pend - p); - if (!eol) - break; - p = eol + 1; - if (*addr == '#' || *addr == '\n') - continue; - len = hstrlen(addr); - if (len > MAX_ADDRLEN) - continue; - name = addr + len; - while (name < eol && isspace(*name)) - ++name; - while (name < eol) { - len = hstrlen(name); - if (len == 0) - break; - if (len < MAX_HOSTLEN) { - struct hcent *ent; - if (c_alloc <= hcfile.c_len) { - struct hcent *c_data; - c_alloc += HCFILE_ALLOC_SIZE; - c_data = realloc(hcfile.c_data, c_alloc * sizeof(struct hcent)); - if (!c_data) { - goto oom; - } - hcfile.c_data = c_data; - } - ent = hcfile.c_data + hcfile.c_len; - ent->addr = addr - h_addr; - ent->name = name - h_addr; - ++hcfile.c_len; - } - name += len; - while (name < eol && isspace(*name)) - ++name; - } - } - - qsort(hcfile.c_data, hcfile.c_len, - sizeof(struct hcent), cmp_hcent_name); - - flock(h_fd, LOCK_UN); - - return 0; - -oom: - free(hcfile.c_data); - munmap(hcfile.h_data, hcfile.h_st.st_size); - flock(hcfile.h_fd, LOCK_UN); - close(hcfile.h_fd); - memset(&hcfile, 0, sizeof(struct hcfile)); - return -1; -} - -/* - * Caching version of getaddrinfo. - * - * If we find the requested host name in the cache, use getaddrinfo to - * populate the result for each address we find. - * - * Note glibc and bionic differ in the handling of ai_canonname. POSIX - * says that ai_canonname is only populated in the first result entry. - * glibc does this. bionic populates ai_canonname in all result entries. - * We choose the POSIX/glibc way here. - */ -int hc_getaddrinfo(const char *host, const char *service, - const struct addrinfo *hints, - struct addrinfo **result) -{ - int ret = 0; - struct hcent *ent, *cur; - struct addrinfo *ai; - struct addrinfo rhints; - struct addrinfo *last; - int canonname = 0; - int cmp; - - if (getenv("ANDROID_HOSTS_CACHE_DISABLE") != NULL) - return EAI_SYSTEM; - - /* Avoid needless work and recursion */ - if (hints && (hints->ai_flags & AI_NUMERICHOST)) - return EAI_SYSTEM; - if (!host) - return EAI_SYSTEM; - - pthread_mutex_lock(&hclock); - - if (_hcfilemmap() != 0) { - ret = EAI_SYSTEM; - goto out; - } - ent = _hcfindname(host); - if (!ent) { - ret = EAI_NONAME; - goto out; - } - - if (hints) { - canonname = (hints->ai_flags & AI_CANONNAME); - memcpy(&rhints, hints, sizeof(rhints)); - rhints.ai_flags &= ~AI_CANONNAME; - } - else { - memset(&rhints, 0, sizeof(rhints)); - } - rhints.ai_flags |= AI_NUMERICHOST; - - last = NULL; - cur = ent; - do { - char addrstr[MAX_ADDRLEN]; - struct addrinfo *res; - - hstrcpy(addrstr, hcfile.h_data + cur->addr); - - if (getaddrinfo(addrstr, service, &rhints, &res) == 0) { - if (!last) - (*result)->ai_next = res; - else - last->ai_next = res; - last = res; - while (last->ai_next) - last = last->ai_next; - } - - if(cur + 1 >= hcfile.c_data + hcfile.c_len) - break; - cmp = cmp_hcent_name(cur, cur + 1); - cur = cur + 1; - } - while (!cmp); - - if (last == NULL) { - /* This check is equivalent to (*result)->ai_next == NULL */ - ret = EAI_NODATA; - goto out; - } - - if (canonname) { - ai = (*result)->ai_next; - free(ai->ai_canonname); - ai->ai_canonname = hstrdup(hcfile.h_data + ent->name); - } - -out: - pthread_mutex_unlock(&hclock); - return ret; -} - -/* - * Caching version of gethtbyname. - * - * Note glibc and bionic differ in the handling of aliases. glibc returns - * all aliases for all entries, regardless of whether they match h_addrtype. - * bionic returns only the aliases for the first hosts entry. We return all - * aliases for all IPv4 entries. - * - * Additionally, if an alias is IPv6 and the primary name for an alias also - * has an IPv4 entry, glibc will return the IPv4 address(es), but bionic - * will not. Neither do we. - */ -int hc_gethtbyname(const char *host, int af, struct getnamaddr *info) -{ - int ret = NETDB_SUCCESS; - struct hcent *ent, *cur; - int cmp; - size_t addrlen; - unsigned int naliases = 0; - char *aliases[MAXALIASES]; - unsigned int naddrs = 0; - char *addr_ptrs[MAXADDRS]; - unsigned int n; - - if (getenv("ANDROID_HOSTS_CACHE_DISABLE") != NULL) - return NETDB_INTERNAL; - - switch (af) { - case AF_INET: addrlen = NS_INADDRSZ; break; - case AF_INET6: addrlen = NS_IN6ADDRSZ; break; - default: - return NETDB_INTERNAL; - } - - pthread_mutex_lock(&hclock); - - if (_hcfilemmap() != 0) { - ret = NETDB_INTERNAL; - goto out; - } - - ent = _hcfindname(host); - if (!ent) { - ret = HOST_NOT_FOUND; - goto out; - } - - cur = ent; - do { - char addr[16]; - char addrstr[MAX_ADDRLEN]; - char namestr[MAX_HOSTLEN]; - const char *name; - - hstrcpy(addrstr, hcfile.h_data + cur->addr); - if (inet_pton(af, addrstr, &addr) == 1) { - char *aligned; - /* First match is considered the official hostname */ - if (naddrs == 0) { - hstrcpy(namestr, hcfile.h_data + cur->name); - HENT_SCOPY(info->hp->h_name, namestr, info->buf, info->buflen); - } - for (name = hcfile.h_data + cur->name; name; name = _hcnextname(name)) { - if (!hstrcmp(name, host)) - continue; - hstrcpy(namestr, name); - HENT_SCOPY(aliases[naliases], namestr, info->buf, info->buflen); - ++naliases; - if (naliases >= MAXALIASES) - goto nospc; - } - aligned = (char *)ALIGN(info->buf); - if (info->buf != aligned) { - if ((ptrdiff_t)info->buflen < (aligned - info->buf)) - goto nospc; - info->buflen -= (aligned - info->buf); - info->buf = aligned; - } - HENT_COPY(addr_ptrs[naddrs], addr, addrlen, info->buf, info->buflen); - ++naddrs; - if (naddrs >= MAXADDRS) - goto nospc; - } - - if(cur + 1 >= hcfile.c_data + hcfile.c_len) - break; - cmp = cmp_hcent_name(cur, cur + 1); - cur = cur + 1; - } - while (!cmp); - - if (naddrs == 0) { - ret = HOST_NOT_FOUND; - goto out; - } - - addr_ptrs[naddrs++] = NULL; - aliases[naliases++] = NULL; - - /* hp->h_name already populated */ - HENT_ARRAY(info->hp->h_aliases, naliases, info->buf, info->buflen); - for (n = 0; n < naliases; ++n) { - info->hp->h_aliases[n] = aliases[n]; - } - info->hp->h_addrtype = af; - info->hp->h_length = addrlen; - HENT_ARRAY(info->hp->h_addr_list, naddrs, info->buf, info->buflen); - for (n = 0; n < naddrs; ++n) { - info->hp->h_addr_list[n] = addr_ptrs[n]; - } - -out: - pthread_mutex_unlock(&hclock); - *info->he = ret; - return ret; - -nospc: - ret = NETDB_INTERNAL; - goto out; -} diff --git a/LeOS/hosts_cache.h b/LeOS/hosts_cache.h deleted file mode 100644 index fa5488f5..00000000 --- a/LeOS/hosts_cache.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -struct getnamaddr; - -int hc_getaddrinfo(const char *host, const char *service, - const struct addrinfo *hints, - struct addrinfo **result); - -int hc_gethtbyname(const char *host, int af, struct getnamaddr *info); diff --git a/LeOS/vendor_hardware-overlay.patch b/LeOS/vendor_hardware-overlay.patch deleted file mode 100644 index 3a53dac9..00000000 --- a/LeOS/vendor_hardware-overlay.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/overlay.mk b/overlay.mk -index df2d488..f3f3589 100755 ---- a/overlay.mk -+++ b/overlay.mk -@@ -21,6 +21,7 @@ PRODUCT_PACKAGES += \ - treble-overlay-duoqin-qin2pro \ - treble-overlay-essential-ph_1 \ - treble-overlay-fairphone-fp3 \ -+ treble-overlay-fairphone-fp4 \ - treble-overlay-highpriomisc \ - treble-overlay-htc-exodus1 \ - treble-overlay-htc-u12plus \ -@@ -237,6 +238,7 @@ PRODUCT_PACKAGES += \ - treble-overlay-tethering-nobpf \ - treble-overlay-umidigi-A3S \ - treble-overlay-umidigi-power \ -+ treble-overlay-umidigi-A5pro \ - treble-overlay-unihertz-jelly2 \ - treble-overlay-vivo-y20 \ - treble-overlay-vivo-y20-systemui \ -@@ -264,6 +266,7 @@ PRODUCT_PACKAGES += \ - treble-overlay-xiaomi-mimix3-systemui \ - treble-overlay-xiaomi-mipad4 \ - treble-overlay-xiaomi-mipad5pro5g \ -+ treble-overlay-xiaomi-mipad5 \ - treble-overlay-xiaomi-miplay \ - treble-overlay-xiaomi-pocof1 \ - treble-overlay-xiaomi-pocom3pro5g \ diff --git a/LeOS/vendor_hardware_overlay.patch b/LeOS/vendor_hardware_overlay.patch deleted file mode 100644 index a1d771f6..00000000 --- a/LeOS/vendor_hardware_overlay.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/HighPriorityMisc/res/xml/config_webview_packages.xml b/HighPriorityMisc/res/xml/config_webview_packages.xml -index 6abcfe2..74ae2ee 100644 ---- a/HighPriorityMisc/res/xml/config_webview_packages.xml -+++ b/HighPriorityMisc/res/xml/config_webview_packages.xml -@@ -39,7 +39,6 @@ - - - -- -- MIIDbTCCAlWgAwIBAgIEHcsmjjANBgkqhkiG9w0BAQsFADBmMQswCQYDVQQGEwJERTEQMA4GA1UECBMHVW5rbm93bjEPMA0GA1UEBxMGQmVybGluMRAwDgYDVQQKEwdCcm9taXRlMRAwDgYDVQQLEwdCcm9taXRlMRAwDgYDVQQDEwdjc2FnYW41MCAXDTE4MDExOTA3MjE1N1oYDzIwNjgwMTA3MDcyMTU3WjBmMQswCQYDVQQGEwJERTEQMA4GA1UECBMHVW5rbm93bjEPMA0GA1UEBxMGQmVybGluMRAwDgYDVQQKEwdCcm9taXRlMRAwDgYDVQQLEwdCcm9taXRlMRAwDgYDVQQDEwdjc2FnYW41MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtakjGj0eTavbBB2vWXj8KBixWn4zgXAKc+yGFu3SLEGF1VB5aJWwcMHxVI55yH/8M2eNnJP0BkSidfKgPVcm1sk/GrNEs9uk5sWod9byO5M5QWQmGP2REeTd6J0BVVVaMp2MZnqeR3Su3pwFzrSwTqIGyf8dkPSEz7ifj792+EeRNrov4oRQK7lIfqInzwc4d34wU069Lrw6m7J7HM0KbRYISsWMiYj025Qg+dTrtdWt7jbdcj7htW0eYyJoLd90+s43RWnOpENmWpcWv1EVPxUD4mCdV9idYwoHRIESpSu9IWvqDZp1VoRc43nLgsNfNBwmYdTkIaPiz1m7TBcr7QIDAQABoyEwHzAdBgNVHQ4EFgQUuWoGd7W7wMyQ1pOdjiMv10YHTR0wDQYJKoZIhvcNAQELBQADggEBAA7iw6eKz+T8HIpKDoDcX1Ywjn9JUzuCFu20LnsLzreO/Pog1xErYjdLAS7LTZokfbAnitBskO9QhV9BYkDiM0Qr5v2/HsJTtxa1mz9ywCcI36jblMyuXFj8tuwQI9/t9i+Fc3+bOFBV3t7djPo9qX1dIK0lZ6s8HcIhaCNdqm65fH+nWhC/H9djqC6qOtrkTiACKEcHQ4a/5dfROU0q0M4bS4YuiaAQWgjiGbik4LrZ8wZX1aqJCLt0Hs7MzXyyf0cRSO11FIOViHwzh6WTZGufq2J3YBFXPond8kLxkKL3LNezbi5yTcecxsbKQ6OS46CnIKcy/M8asSreLpoCDvw= -- -+ -+ - - diff --git a/build-u.sh b/build-u.sh deleted file mode 100644 index 308164d4..00000000 --- a/build-u.sh +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/bash - -MONTH="date +%B" - -echo -echo "--------------------------------------" -echo " LeOS-U Buildbot " -echo " by " -echo " harvey186 " -echo "--------------------------------------" -echo - -git clone https://github.com/ponces/treble_aosp -b android-14.0 - -git clone https://github.com/ponces/vendor_ponces.git -b android-14.0 vendor/ponces - -set -e - -initRepos() { - if [ ! -d .repo ]; then - echo "--> Initializing workspace" - repo init -u https://android.googlesource.com/platform/manifest -b android-14.0.0_r17 --git-lfs - echo - echo "--> Preparing local manifest" - mkdir -p .repo/local_manifests - cp treble_aosp/build/manifest.xml .repo/local_manifests/aosp.xml - cp LeOS/leos.xml .repo/local_manifests/leos.xml - cp LeOS/removeAOSP.xml .repo/local_manifests/remove.xml - echo - fi -} - -syncRepos() { - echo "--> Syncing repos" - repo sync -c --force-sync --no-clone-bundle --no-tags -j$(nproc --all) - echo -} - -applyPatches() { - echo "--> Applying TrebleDroid patches" - bash treble_aosp/patch.sh treble_aosp trebledroid - echo - - echo "--> Applying ponces personal patches" - rm treble_aosp/patches/personal/platform_frameworks_base/0001-gmscompat-Change-attestation-and-instrumentation-to-.patch - rm treble_aosp/patches/personal/platform_frameworks_base/0002-gmscompat-Spoof-Pixel-XL-for-Google-Photos.patch - rm treble_aosp/patches/personal/platform_frameworks_base/0007-permissions-Pre-grant-google-restore-permissions.patch - rm -R treble_aosp/patches/personal/platform_frameworks_base/0008-feat-Add-Lockscreen-Weather-with-OmniJaws-1-2.patch - rm -R treble_aosp/patches/personal/platform_packages_apps_Settings/0001-feat-Add-Lockscreen-Weather-with-OmniJaws-2-2.patch - rm treble_aosp/patches/personal/platform_build/0001-Remove-su-from-vanilla-builds.patch - bash treble_aosp/patch.sh treble_aosp personal - echo - - echo "--> Applying LeOS patches" - mv patches/leos treble_aosp/patches/leos - bash treble_aosp/patch.sh treble_aosp leos - cp LeOS/instrumentation_test_list.mk plattform_testing/build/tasks/tests/ - cp LeOS/platform_test_list.mk plattform_testing/build/tasks/tests/ - echo - - echo "--> Generating makefiles" - cd device/phh/treble - cp treble_aosp/build/aosp.mk device/phh/treble/ - bash generate.sh aosp - cd ../../.. - echo -} - -setupEnv() { - echo "--> Setting up build environment" - source build/envsetup.sh &>/dev/null - mkdir -p $BD - echo -} - -buildTrebleApp() { - echo "--> Building treble_app" - cd treble_app - bash build.sh release - cp TrebleApp.apk ../vendor/hardware_overlay/TrebleApp/app.apk - cd .. - echo -} - -buildVanillaVariant() { - echo "--> Building treble_arm64_bvS" - export WITHOUT_CHECK_API=true - export USE_CCACHE=1 - export CCACHE_SIZE=50G - export WITH_SU=true - lunch leos_arm64_bvS-userdebug - #make installclean - make -j12 RELAX_USES_LIBRARY_CHECK=true systemimage - echo - echo "--> Building treble_a64_bvS" - export WITHOUT_CHECK_API=true - export USE_CCACHE=1 - export CCACHE_SIZE=50G - export WITH_SU=true - lunch leos_a64_bvS-userdebug - #make installclean - make -j12 RELAX_USES_LIBRARY_CHECK=true systemimage - - echo "--> Building LeOS-U-VNDKLITE-arm64-bvS.img" - cd treble_adapter - sudo bash lite-adapter.sh 64 ../out/target/product/leos_arm64_ab/system.img - mv s.img LeOS-U-VNDKLITE-arm64-bvS.img - sudo rm -rf d tmp - - echo "--> Building LeOS-U-VNDKLITE-arm64-bvN" - sudo bash lite-adapterN.sh 64 ../out/target/product/leos_arm64_ab/system.img - mv s.img LeOS-U-VNDKLITE-arm64-bvN.img - sudo rm -rf d tmp - cd .. - echo - - echo "--> Building LeOS-U-VNDKLITE-a64-bvS.img" - cd treble_adapter - sudo bash lite-adapterSa64.sh 32 ../out/target/product/leos_a64_ab/system.img - mv s.img LeOS-U-VNDKLITE-a64-bvS.img - sudo rm -rf d tmp - - echo "--> Building LeOS-U-VNDKLITE-a64-bvN" - sudo bash lite-adapterNa64.sh 32 ../out/target/product/leos_a64_ab/system.img - mv s.img LeOS-U-VNDKLITE-a64-bvN.img - sudo rm -rf d tmp - cd .. - echo - - - cd prebuilts/prebuiltapks/foss_nano/ - bash update.sh - cd ../../.. - - echo "--> Building treble_arm64_bvN" - export WITHOUT_CHECK_API=true - export USE_CCACHE=1 - export CCACHE_SIZE=50G - export WITH_SU=true - lunch leos_arm64_bvN-userdebug - #make installclean - make -j12 RELAX_USES_LIBRARY_CHECK=true systemimage - echo - echo "--> Building treble_a64_bvN" - export WITHOUT_CHECK_API=true - export USE_CCACHE=1 - export CCACHE_SIZE=50G - export WITH_SU=true - lunch leos_a64_bvN-userdebug - #make installclean - make -j12 RELAX_USES_LIBRARY_CHECK=true systemimage - -} - -generatePackages() { - echo "--> Generating packages" - cp out/target/product/leos_arm64_ab/system.img treble_adapter/LeOS-U-VNDK-arm64_bvN.img - cp out/target/product/leos_a64_ab/system.img treble_adapter/LeOS-U-VNDK-a64-bvN.img - cd treble_adapter - xz -vT0 *.img - cp *.img.xz /media/ich/exSSD2/leos-cloud/LeOS-Files/LeOS-U/$MONTH/ - echo -} - -echo "READY" - - -START=$(date +%s) - -initRepos -syncRepos -applyPatches -setupEnv -buildTrebleApp -buildVanillaVariant -generatePackages - -END=$(date +%s) -ELAPSEDM=$(($(($END-$START))/60)) -ELAPSEDS=$(($(($END-$START))-$ELAPSEDM*60)) - -echo "--> Buildbot completed in $ELAPSEDM minutes and $ELAPSEDS seconds" -echo