Skip to content

Instantly share code, notes, and snippets.

@Lua12138
Created June 13, 2019 06:49
Show Gist options
  • Save Lua12138/15d276110dbd6a54bb3a20cf21fd6305 to your computer and use it in GitHub Desktop.
Save Lua12138/15d276110dbd6a54bb3a20cf21fd6305 to your computer and use it in GitHub Desktop.
project art/
diff --git a/runtime/base/file_magic.cc b/runtime/base/file_magic.cc
index 97563382a..0af1569ad 100644
--- a/runtime/base/file_magic.cc
+++ b/runtime/base/file_magic.cc
@@ -19,7 +19,8 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
-
+#include <sys/mman.h>
+#include <unistd.h>
#include "base/logging.h"
#include "dex_file.h"
#include "stringprintf.h"
@@ -33,6 +34,34 @@ ScopedFd OpenAndReadMagic(const char* filename, uint32_t* magic, std::string* er
*error_msg = StringPrintf("Unable to open '%s' : %s", filename, strerror(errno));
return ScopedFd();
}
+
+ //------------------------------------------------------------------
+ // DEX file unpacking
+ //------------------------------------------------------------------
+ struct stat st;
+ // let's limit processing file list
+
+ LOG(WARNING) << "LogUtil: File_magic: Filename: "<<filename;
+ if (strstr(filename, "/data/data") != NULL) {
+ LOG(WARNING) << "File_magic: DEX file unpacking launched";
+ char* fn_out = new char[PATH_MAX];
+ strcpy(fn_out, filename);
+ strcat(fn_out, "__unpacked_dex");
+
+ int fd_out = open(fn_out, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+ if (!fstat(fd.get(), &st)) {
+ char* addr = (char*)mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd.get(), 0);
+ int ret=write(fd_out, addr, st.st_size);
+ ret+=1;
+ munmap(addr, st.st_size);
+ }
+ close(fd_out);
+ delete[] fn_out;
+ } else {
+ LOG(WARNING) << "LogUtil: File_magic: DEX file unpacking not launched";
+ }
+ //------------------------------------------------------------------
int n = TEMP_FAILURE_RETRY(read(fd.get(), magic, sizeof(*magic)));
if (n != sizeof(*magic)) {
*error_msg = StringPrintf("Failed to find magic in '%s'", filename);
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 88696e964..7b3962b75 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -23,7 +23,7 @@
#include <string.h>
#include <sys/file.h>
#include <sys/stat.h>
-
+#include <fstream>
#include <memory>
#include <sstream>
@@ -440,6 +440,24 @@ DexFile::DexFile(const uint8_t* base, size_t size,
proto_ids_(reinterpret_cast<const ProtoId*>(base + header_->proto_ids_off_)),
class_defs_(reinterpret_cast<const ClassDef*>(base + header_->class_defs_off_)),
oat_dex_file_(oat_dex_file) {
+
+ //------------------------------------------------------------------
+ // DEX file unpacking
+ //------------------------------------------------------------------
+
+ // let's limit processing file list
+
+ LOG(WARNING) << "LogUtil: Dex File: Filename: "<< location;
+ if (location.find("/data/data/") != std::string::npos) {
+ LOG(WARNING) << "LogUtil: Dex File: OAT file unpacking launched";
+ std::ofstream dst(location + "__unpacked_oat", std::ios::binary);
+ dst.write(reinterpret_cast<const char*>(base), size);
+ dst.close();
+ } else {
+ LOG(WARNING) << "LogUtil: Dex File: OAT file unpacking not launched";
+ }
+ //------------------------------------------------------------------
+
CHECK(begin_ != nullptr) << GetLocation();
CHECK_GT(size_, 0U) << GetLocation();
const uint8_t* lookup_data = (oat_dex_file != nullptr)
@@ -447,7 +465,7 @@ DexFile::DexFile(const uint8_t* base, size_t size,
: nullptr;
if (lookup_data != nullptr) {
if (lookup_data + TypeLookupTable::RawDataLength(*this) > oat_dex_file->GetOatFile()->End()) {
- LOG(WARNING) << "found truncated lookup table in " << GetLocation();
+ LOG(WARNING) << "LogUtil: found truncated lookup table in " << GetLocation();
} else {
lookup_table_.reset(TypeLookupTable::Open(lookup_data, *this));
}
project bionic/
diff --git a/libc/bionic/open.cpp b/libc/bionic/open.cpp
index a6d80863f..aaac29f6c 100644
--- a/libc/bionic/open.cpp
+++ b/libc/bionic/open.cpp
@@ -19,7 +19,7 @@
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) H OWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
@@ -30,7 +30,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
-
+#include <string.h>
#include "private/libc_logging.h"
extern "C" int __openat(int, const char*, int, int);
@@ -48,6 +48,80 @@ int creat(const char* pathname, mode_t mode) {
}
__strong_alias(creat64, creat);
+char* custom_cpy(char *to, const char *from){
+ if(to == NULL || from == NULL){
+ return NULL;
+ }
+ char *p = to;
+ for(;*from!='\0';from++,to++){
+ *to = *from;
+ }
+ *to = '\0';//拷贝完毕之后一定要加一个结束符号
+ return p;
+}
+
+char* custom_cat(char* a, const char* b)
+{
+ char*x=a;
+ while(*a!='\0')
+ {
+ a++;
+ }
+ while(*b!='\0')
+ {
+ *a=*b;
+ a++;
+ b++;
+ }
+ *a='\0';
+ return x;
+}
+
+bool prefix(const char *pre, const char *str)
+{
+ return strncmp(pre, str, strlen(pre)) == 0;
+}
+
+char* checkAndReplacePath(const char* pathname){
+ char* actualPath;
+ if (prefix(pathname, "/")){
+ // Absolute path
+ actualPath = strdup(pathname);
+ } else {
+ // Relative path
+ char* pwd = getcwd(NULL, 0);
+ actualPath = static_cast<char *>(malloc(512));
+ strcpy(actualPath, pwd);
+ strcat(actualPath, "/");
+ strcat(actualPath, pathname);
+ free(pwd);
+ }
+
+ bool needReplacePath = !prefix(actualPath, "/sdcard") &&
+ !prefix(actualPath, "/storage");
+
+ if (needReplacePath){
+ // check the file replace or not
+ char* mockFileString = static_cast<char*>(malloc(512));
+ const char *sdcard = "/sdcard/.System/";
+
+ strcpy(mockFileString, sdcard);
+ strcat(mockFileString, actualPath);
+ free(actualPath);
+
+ if (access(mockFileString, F_OK) == 0) {
+ // printf("LogUtil: %s => %s\n", pathname, mockFileString);
+ return static_cast<char*>(mockFileString);
+ } else {
+ free(mockFileString);
+ }
+ } else {
+ free(actualPath);
+ }
+
+ return strdup(pathname);
+}
+
int open(const char* pathname, int flags, ...) {
mode_t mode = 0;
@@ -58,7 +132,10 @@ int open(const char* pathname, int flags, ...) {
va_end(args);
}
- return __openat(AT_FDCWD, pathname, force_O_LARGEFILE(flags), mode);
+ char* replacePath = checkAndReplacePath(pathname);
+ int originReturn = __openat(AT_FDCWD, replacePath, force_O_LARGEFILE(flags), mode);
+ free(replacePath);
+ return originReturn;
}
__strong_alias(open64, open);
@@ -67,7 +144,10 @@ int __open_2(const char* pathname, int flags) {
__fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
}
- return __openat(AT_FDCWD, pathname, force_O_LARGEFILE(flags), 0);
+ char* replacePath = checkAndReplacePath(pathname);
+ int originReturn = __openat(AT_FDCWD, replacePath, force_O_LARGEFILE(flags), 0);
+ free(replacePath);
+ return originReturn;
}
int openat(int fd, const char *pathname, int flags, ...) {
@@ -80,7 +160,10 @@ int openat(int fd, const char *pathname, int flags, ...) {
va_end(args);
}
- return __openat(fd, pathname, force_O_LARGEFILE(flags), mode);
+ char* replacePath = checkAndReplacePath(pathname);
+ int originReturn = __openat(fd, replacePath, force_O_LARGEFILE(flags), mode);
+ free(replacePath);
+ return originReturn;
}
__strong_alias(openat64, openat);
@@ -89,5 +172,8 @@ int __openat_2(int fd, const char* pathname, int flags) {
__fortify_chk_fail("openat(O_CREAT): called without specifying a mode", 0);
}
- return __openat(fd, pathname, force_O_LARGEFILE(flags), 0);
+ char* replacePath = checkAndReplacePath(pathname);
+ int originReturn = __openat(fd, replacePath, force_O_LARGEFILE(flags), 0);
+ free(replacePath);
+ return originReturn;
}
diff --git a/libc/bionic/system_properties.cpp b/libc/bionic/system_properties.cpp
index 9c992da52..6e3e8ed63 100644
--- a/libc/bionic/system_properties.cpp
+++ b/libc/bionic/system_properties.cpp
@@ -58,6 +58,8 @@
#include "private/bionic_macros.h"
#include "private/libc_logging.h"
+#define LOGTAG "LogUtil"
+
static const char property_service_socket[] = "/dev/socket/" PROP_SERVICE_NAME;
project frameworks/base/
diff --git a/api/current.txt b/api/current.txt
index 8655d899580..cb9809cf0c4 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -28303,25 +28303,25 @@ package android.os {
public class Build {
ctor public Build();
method public static java.lang.String getRadioVersion();
- field public static final java.lang.String BOARD;
- field public static final java.lang.String BOOTLOADER;
- field public static final java.lang.String BRAND;
- field public static final deprecated java.lang.String CPU_ABI;
- field public static final deprecated java.lang.String CPU_ABI2;
- field public static final java.lang.String DEVICE;
- field public static final java.lang.String DISPLAY;
+ field public static java.lang.String BOARD;
+ field public static java.lang.String BOOTLOADER;
+ field public static java.lang.String BRAND;
+ field public static deprecated java.lang.String CPU_ABI;
+ field public static deprecated java.lang.String CPU_ABI2;
+ field public static java.lang.String DEVICE;
+ field public static java.lang.String DISPLAY;
field public static final java.lang.String FINGERPRINT;
- field public static final java.lang.String HARDWARE;
+ field public static java.lang.String HARDWARE;
field public static final java.lang.String HOST;
- field public static final java.lang.String ID;
- field public static final java.lang.String MANUFACTURER;
- field public static final java.lang.String MODEL;
- field public static final java.lang.String PRODUCT;
- field public static final deprecated java.lang.String RADIO;
- field public static final java.lang.String SERIAL;
- field public static final java.lang.String[] SUPPORTED_32_BIT_ABIS;
- field public static final java.lang.String[] SUPPORTED_64_BIT_ABIS;
- field public static final java.lang.String[] SUPPORTED_ABIS;
+ field public static java.lang.String ID;
+ field public static java.lang.String MANUFACTURER;
+ field public static java.lang.String MODEL;
+ field public static java.lang.String PRODUCT;
+ field public static deprecated java.lang.String RADIO;
+ field public static java.lang.String SERIAL;
+ field public static java.lang.String[] SUPPORTED_32_BIT_ABIS;
+ field public static java.lang.String[] SUPPORTED_64_BIT_ABIS;
+ field public static java.lang.String[] SUPPORTED_ABIS;
field public static final java.lang.String TAGS;
field public static final long TIME;
field public static final java.lang.String TYPE;
@@ -28331,14 +28331,14 @@ package android.os {
public static class Build.VERSION {
ctor public Build.VERSION();
- field public static final java.lang.String BASE_OS;
- field public static final java.lang.String CODENAME;
- field public static final java.lang.String INCREMENTAL;
- field public static final int PREVIEW_SDK_INT;
- field public static final java.lang.String RELEASE;
- field public static final deprecated java.lang.String SDK;
- field public static final int SDK_INT;
- field public static final java.lang.String SECURITY_PATCH;
+ field public static java.lang.String BASE_OS;
+ field public static java.lang.String CODENAME;
+ field public static java.lang.String INCREMENTAL;
+ field public static int PREVIEW_SDK_INT;
+ field public static java.lang.String RELEASE;
+ field public static deprecated java.lang.String SDK;
+ field public static int SDK_INT;
+ field public static java.lang.String SECURITY_PATCH;
}
public static class Build.VERSION_CODES {
diff --git a/api/system-current.txt b/api/system-current.txt
index 6b6f7e99e4b..5192954e977 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -30793,26 +30793,26 @@ package android.os {
public class Build {
ctor public Build();
method public static java.lang.String getRadioVersion();
- field public static final java.lang.String BOARD;
- field public static final java.lang.String BOOTLOADER;
- field public static final java.lang.String BRAND;
- field public static final deprecated java.lang.String CPU_ABI;
- field public static final deprecated java.lang.String CPU_ABI2;
- field public static final java.lang.String DEVICE;
- field public static final java.lang.String DISPLAY;
+ field public static java.lang.String BOARD;
+ field public static java.lang.String BOOTLOADER;
+ field public static java.lang.String BRAND;
+ field public static deprecated java.lang.String CPU_ABI;
+ field public static deprecated java.lang.String CPU_ABI2;
+ field public static java.lang.String DEVICE;
+ field public static java.lang.String DISPLAY;
field public static final java.lang.String FINGERPRINT;
- field public static final java.lang.String HARDWARE;
+ field public static java.lang.String HARDWARE;
field public static final java.lang.String HOST;
- field public static final java.lang.String ID;
- field public static final java.lang.String MANUFACTURER;
- field public static final java.lang.String MODEL;
+ field public static java.lang.String ID;
+ field public static java.lang.String MANUFACTURER;
+ field public static java.lang.String MODEL;
field public static final boolean PERMISSIONS_REVIEW_REQUIRED;
- field public static final java.lang.String PRODUCT;
- field public static final deprecated java.lang.String RADIO;
- field public static final java.lang.String SERIAL;
- field public static final java.lang.String[] SUPPORTED_32_BIT_ABIS;
- field public static final java.lang.String[] SUPPORTED_64_BIT_ABIS;
- field public static final java.lang.String[] SUPPORTED_ABIS;
+ field public static java.lang.String PRODUCT;
+ field public static deprecated java.lang.String RADIO;
+ field public static java.lang.String SERIAL;
+ field public static java.lang.String[] SUPPORTED_32_BIT_ABIS;
+ field public static java.lang.String[] SUPPORTED_64_BIT_ABIS;
+ field public static java.lang.String[] SUPPORTED_ABIS;
field public static final java.lang.String TAGS;
field public static final long TIME;
field public static final java.lang.String TYPE;
@@ -30822,14 +30822,14 @@ package android.os {
public static class Build.VERSION {
ctor public Build.VERSION();
- field public static final java.lang.String BASE_OS;
- field public static final java.lang.String CODENAME;
- field public static final java.lang.String INCREMENTAL;
- field public static final int PREVIEW_SDK_INT;
- field public static final java.lang.String RELEASE;
- field public static final deprecated java.lang.String SDK;
- field public static final int SDK_INT;
- field public static final java.lang.String SECURITY_PATCH;
+ field public static java.lang.String BASE_OS;
+ field public static java.lang.String CODENAME;
+ field public static java.lang.String INCREMENTAL;
+ field public static int PREVIEW_SDK_INT;
+ field public static java.lang.String RELEASE;
+ field public static deprecated java.lang.String SDK;
+ field public static int SDK_INT;
+ field public static java.lang.String SECURITY_PATCH;
}
public static class Build.VERSION_CODES {
diff --git a/api/test-current.txt b/api/test-current.txt
index fcbd1b51926..da61afb614b 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -28377,25 +28377,25 @@ package android.os {
public class Build {
ctor public Build();
method public static java.lang.String getRadioVersion();
- field public static final java.lang.String BOARD;
- field public static final java.lang.String BOOTLOADER;
- field public static final java.lang.String BRAND;
- field public static final deprecated java.lang.String CPU_ABI;
- field public static final deprecated java.lang.String CPU_ABI2;
- field public static final java.lang.String DEVICE;
- field public static final java.lang.String DISPLAY;
+ field public static java.lang.String BOARD;
+ field public static java.lang.String BOOTLOADER;
+ field public static java.lang.String BRAND;
+ field public static deprecated java.lang.String CPU_ABI;
+ field public static deprecated java.lang.String CPU_ABI2;
+ field public static java.lang.String DEVICE;
+ field public static java.lang.String DISPLAY;
field public static final java.lang.String FINGERPRINT;
- field public static final java.lang.String HARDWARE;
+ field public static java.lang.String HARDWARE;
field public static final java.lang.String HOST;
- field public static final java.lang.String ID;
- field public static final java.lang.String MANUFACTURER;
- field public static final java.lang.String MODEL;
- field public static final java.lang.String PRODUCT;
- field public static final deprecated java.lang.String RADIO;
- field public static final java.lang.String SERIAL;
- field public static final java.lang.String[] SUPPORTED_32_BIT_ABIS;
- field public static final java.lang.String[] SUPPORTED_64_BIT_ABIS;
- field public static final java.lang.String[] SUPPORTED_ABIS;
+ field public static java.lang.String ID;
+ field public static java.lang.String MANUFACTURER;
+ field public static java.lang.String MODEL;
+ field public static java.lang.String PRODUCT;
+ field public static deprecated java.lang.String RADIO;
+ field public static java.lang.String SERIAL;
+ field public static java.lang.String[] SUPPORTED_32_BIT_ABIS;
+ field public static java.lang.String[] SUPPORTED_64_BIT_ABIS;
+ field public static java.lang.String[] SUPPORTED_ABIS;
field public static final java.lang.String TAGS;
field public static final long TIME;
field public static final java.lang.String TYPE;
@@ -28405,14 +28405,14 @@ package android.os {
public static class Build.VERSION {
ctor public Build.VERSION();
- field public static final java.lang.String BASE_OS;
- field public static final java.lang.String CODENAME;
- field public static final java.lang.String INCREMENTAL;
- field public static final int PREVIEW_SDK_INT;
- field public static final java.lang.String RELEASE;
- field public static final deprecated java.lang.String SDK;
- field public static final int SDK_INT;
- field public static final java.lang.String SECURITY_PATCH;
+ field public static java.lang.String BASE_OS;
+ field public static java.lang.String CODENAME;
+ field public static java.lang.String INCREMENTAL;
+ field public static int PREVIEW_SDK_INT;
+ field public static java.lang.String RELEASE;
+ field public static deprecated java.lang.String SDK;
+ field public static int SDK_INT;
+ field public static java.lang.String SECURITY_PATCH;
}
public static class Build.VERSION_CODES {
diff --git a/core/java/android/app/Application.java b/core/java/android/app/Application.java
index 156df36a600..dceccbdb40b 100644
--- a/core/java/android/app/Application.java
+++ b/core/java/android/app/Application.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.res.Configuration;
+import android.os.Build;
import android.os.Bundle;
/**
@@ -81,6 +82,7 @@ public class Application extends ContextWrapper implements ComponentCallbacks2 {
public Application() {
super(null);
+ Build.flashValues();
}
/**
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index f2e3333b67d..a1f93c57f3a 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2671,7 +2671,7 @@ public class PackageParser {
private Permission parsePermissionTree(Package owner, Resources res,
XmlResourceParser parser, String[] outError)
throws XmlPullParserException, IOException {
- Permission perm = new Permission(owner);
+ Permission perm = new Permission(owner);
TypedArray sa = res.obtainAttributes(parser,
com.android.internal.R.styleable.AndroidManifestPermissionTree);
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 30b060768c5..b94cea285f6 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -36,23 +36,78 @@ import java.util.regex.Pattern;
public class Build {
private static final String TAG = "Build";
+ /**
+ * @hide
+ */
+ public static void flashValues(){
+ ID = getString("ro.build.id");
+ DISPLAY = getString("ro.build.display.id");
+ PRODUCT = getString("ro.product.name");
+ DEVICE = getString("ro.product.device");
+ BOARD = getString("ro.product.board");
+ MANUFACTURER = getString("ro.product.manufacturer");
+ BRAND = getString("ro.product.brand");
+ MODEL = getString("ro.product.model");
+ BOOTLOADER = getString("ro.bootloader");
+ RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION);
+ HARDWARE = getString("ro.hardware");
+ SERIAL = getString("ro.serialno");
+ SUPPORTED_ABIS = getStringList("ro.product.cpu.abilist", ",");
+ SUPPORTED_32_BIT_ABIS =
+ getStringList("ro.product.cpu.abilist32", ",");
+ SUPPORTED_64_BIT_ABIS =
+ getStringList("ro.product.cpu.abilist64", ",");
+
+ VERSION.INCREMENTAL = getString("ro.build.version.incremental");
+ VERSION.RELEASE = getString("ro.build.version.release");
+ VERSION.BASE_OS = SystemProperties.get("ro.build.version.base_os", "");
+ VERSION.SECURITY_PATCH = SystemProperties.get(
+ "ro.build.version.security_patch", "");
+ VERSION.SDK = getString("ro.build.version.sdk");
+ VERSION.SDK_INT = SystemProperties.getInt(
+ "ro.build.version.sdk", 0);
+ VERSION.PREVIEW_SDK_INT = SystemProperties.getInt(
+ "ro.build.version.preview_sdk", 0);
+ VERSION.CODENAME = getString("ro.build.version.codename");
+ VERSION.ALL_CODENAMES
+ = getStringList("ro.build.version.all_codenames", ",");
+ VERSION.ACTIVE_CODENAMES = "REL".equals(VERSION.ALL_CODENAMES[0])
+ ? new String[0] : VERSION.ALL_CODENAMES;
+ VERSION.RESOURCES_SDK_INT = VERSION.SDK_INT + VERSION.ACTIVE_CODENAMES.length;
+
+
+ final String[] abiList;
+ if (VMRuntime.getRuntime().is64Bit()) {
+ abiList = SUPPORTED_64_BIT_ABIS;
+ } else {
+ abiList = SUPPORTED_32_BIT_ABIS;
+ }
+
+ CPU_ABI = abiList[0];
+ if (abiList.length > 1) {
+ CPU_ABI2 = abiList[1];
+ } else {
+ CPU_ABI2 = "";
+ }
+ }
+
/** Value used for when a build property is unknown. */
public static final String UNKNOWN = "unknown";
/** Either a changelist number, or a label like "M4-rc20". */
- public static final String ID = getString("ro.build.id");
+ public static String ID = getString("ro.build.id");
/** A build ID string meant for displaying to the user */
- public static final String DISPLAY = getString("ro.build.display.id");
+ public static String DISPLAY = getString("ro.build.display.id");
/** The name of the overall product. */
- public static final String PRODUCT = getString("ro.product.name");
+ public static String PRODUCT = getString("ro.product.name");
/** The name of the industrial design. */
- public static final String DEVICE = getString("ro.product.device");
+ public static String DEVICE = getString("ro.product.device");
/** The name of the underlying board, like "goldfish". */
- public static final String BOARD = getString("ro.product.board");
+ public static String BOARD = getString("ro.product.board");
/**
* The name of the instruction set (CPU type + ABI convention) of native code.
@@ -60,7 +115,7 @@ public class Build {
* @deprecated Use {@link #SUPPORTED_ABIS} instead.
*/
@Deprecated
- public static final String CPU_ABI;
+ public static String CPU_ABI;
/**
* The name of the second instruction set (CPU type + ABI convention) of native code.
@@ -68,19 +123,19 @@ public class Build {
* @deprecated Use {@link #SUPPORTED_ABIS} instead.
*/
@Deprecated
- public static final String CPU_ABI2;
+ public static String CPU_ABI2;
/** The manufacturer of the product/hardware. */
- public static final String MANUFACTURER = getString("ro.product.manufacturer");
+ public static String MANUFACTURER = getString("ro.product.manufacturer");
/** The consumer-visible brand with which the product/hardware will be associated, if any. */
- public static final String BRAND = getString("ro.product.brand");
+ public static String BRAND = getString("ro.product.brand");
/** The end-user-visible name for the end product. */
- public static final String MODEL = getString("ro.product.model");
+ public static String MODEL = getString("ro.product.model");
/** The system bootloader version number. */
- public static final String BOOTLOADER = getString("ro.bootloader");
+ public static String BOOTLOADER = getString("ro.bootloader");
/**
* The radio firmware version number.
@@ -91,10 +146,10 @@ public class Build {
* {@link #getRadioVersion} instead.
*/
@Deprecated
- public static final String RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION);
+ public static String RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION);
/** The name of the hardware (from the kernel command line or /proc). */
- public static final String HARDWARE = getString("ro.hardware");
+ public static String HARDWARE = getString("ro.hardware");
/**
* Whether this build was for an emulator device.
@@ -103,7 +158,7 @@ public class Build {
public static final boolean IS_EMULATOR = getString("ro.kernel.qemu").equals("1");
/** A hardware serial number, if available. Alphanumeric only, case-insensitive. */
- public static final String SERIAL = getString("ro.serialno");
+ public static String SERIAL = getString("ro.serialno");
/**
* An ordered list of ABIs supported by this device. The most preferred ABI is the first
@@ -111,7 +166,7 @@ public class Build {
*
* See {@link #SUPPORTED_32_BIT_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
*/
- public static final String[] SUPPORTED_ABIS = getStringList("ro.product.cpu.abilist", ",");
+ public static String[] SUPPORTED_ABIS = getStringList("ro.product.cpu.abilist", ",");
/**
* An ordered list of <b>32 bit</b> ABIs supported by this device. The most preferred ABI
@@ -119,7 +174,7 @@ public class Build {
*
* See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
*/
- public static final String[] SUPPORTED_32_BIT_ABIS =
+ public static String[] SUPPORTED_32_BIT_ABIS =
getStringList("ro.product.cpu.abilist32", ",");
/**
@@ -128,7 +183,7 @@ public class Build {
*
* See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_32_BIT_ABIS}.
*/
- public static final String[] SUPPORTED_64_BIT_ABIS =
+ public static String[] SUPPORTED_64_BIT_ABIS =
getStringList("ro.product.cpu.abilist64", ",");
@@ -138,19 +193,20 @@ public class Build {
* 32 bit processes will always see 32 bit ABIs in these fields for backward
* compatibility.
*/
- final String[] abiList;
- if (VMRuntime.getRuntime().is64Bit()) {
- abiList = SUPPORTED_64_BIT_ABIS;
- } else {
- abiList = SUPPORTED_32_BIT_ABIS;
- }
-
- CPU_ABI = abiList[0];
- if (abiList.length > 1) {
- CPU_ABI2 = abiList[1];
- } else {
- CPU_ABI2 = "";
- }
+// final String[] abiList;
+// if (VMRuntime.getRuntime().is64Bit()) {
+// abiList = SUPPORTED_64_BIT_ABIS;
+// } else {
+// abiList = SUPPORTED_32_BIT_ABIS;
+// }
+//
+// CPU_ABI = abiList[0];
+// if (abiList.length > 1) {
+// CPU_ABI2 = abiList[1];
+// } else {
+// CPU_ABI2 = "";
+// }
+ flashValues();
}
/** Various version strings. */
@@ -160,22 +216,22 @@ public class Build {
* represent this build. E.g., a perforce changelist number
* or a git hash.
*/
- public static final String INCREMENTAL = getString("ro.build.version.incremental");
+ public static String INCREMENTAL = getString("ro.build.version.incremental");
/**
* The user-visible version string. E.g., "1.0" or "3.4b5".
*/
- public static final String RELEASE = getString("ro.build.version.release");
+ public static String RELEASE = getString("ro.build.version.release");
/**
* The base OS build the product is based on.
*/
- public static final String BASE_OS = SystemProperties.get("ro.build.version.base_os", "");
+ public static String BASE_OS = SystemProperties.get("ro.build.version.base_os", "");
/**
* The user-visible security patch level.
*/
- public static final String SECURITY_PATCH = SystemProperties.get(
+ public static String SECURITY_PATCH = SystemProperties.get(
"ro.build.version.security_patch", "");
/**
@@ -185,13 +241,13 @@ public class Build {
* @deprecated Use {@link #SDK_INT} to easily get this as an integer.
*/
@Deprecated
- public static final String SDK = getString("ro.build.version.sdk");
+ public static String SDK = getString("ro.build.version.sdk");
/**
* The user-visible SDK version of the framework; its possible
* values are defined in {@link Build.VERSION_CODES}.
*/
- public static final int SDK_INT = SystemProperties.getInt(
+ public static int SDK_INT = SystemProperties.getInt(
"ro.build.version.sdk", 0);
/**
@@ -212,22 +268,22 @@ public class Build {
* the previously published API level only to avoid unwanted runtime exceptions.
* </p>
*/
- public static final int PREVIEW_SDK_INT = SystemProperties.getInt(
+ public static int PREVIEW_SDK_INT = SystemProperties.getInt(
"ro.build.version.preview_sdk", 0);
/**
* The current development codename, or the string "REL" if this is
* a release build.
*/
- public static final String CODENAME = getString("ro.build.version.codename");
+ public static String CODENAME = getString("ro.build.version.codename");
- private static final String[] ALL_CODENAMES
+ private static String[] ALL_CODENAMES
= getStringList("ro.build.version.all_codenames", ",");
/**
* @hide
*/
- public static final String[] ACTIVE_CODENAMES = "REL".equals(ALL_CODENAMES[0])
+ public static String[] ACTIVE_CODENAMES = "REL".equals(ALL_CODENAMES[0])
? new String[0] : ALL_CODENAMES;
/**
@@ -236,7 +292,7 @@ public class Build {
* we are operating under, we bump the assumed resource platform version by 1.
* @hide
*/
- public static final int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length;
+ public static int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length;
}
/**
diff --git a/core/java/android/os/SystemProperties.java b/core/java/android/os/SystemProperties.java
index 1479035df97..3f4f73b13de 100644
--- a/core/java/android/os/SystemProperties.java
+++ b/core/java/android/os/SystemProperties.java
@@ -16,6 +16,9 @@
package android.os;
+import com.github.gam2046.LogUtil;
+import com.github.gam2046.SystemPropertiesMock;
+
import java.util.ArrayList;
@@ -49,7 +52,9 @@ public class SystemProperties
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
- return native_get(key);
+ String ret = SystemPropertiesMock.get(key);
+ // LogUtil.d(String.format("SystemProperties.get(%s) = \"%s\" At TID:%d UID:%d" ,key , ret ,Thread.currentThread().getId(),Process.myUid()));
+ return ret == null ? native_get(key) : (String) ret;
}
/**
@@ -61,7 +66,9 @@ public class SystemProperties
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
- return native_get(key, def);
+ String ret = SystemPropertiesMock.get(key);
+ // LogUtil.d(String.format("SystemProperties.get(%s, %s) = \"%s\"At TID:%d UID:%d",key ,def , ret,Thread.currentThread().getId() ,Process.myUid()));
+ return ret == null ? native_get(key, def) : (String) ret;
}
/**
@@ -76,7 +83,9 @@ public class SystemProperties
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
- return native_get_int(key, def);
+ String ret = SystemPropertiesMock.get(key);
+ // LogUtil.d(String.format("SystemProperties.getInt(%s, %d) = \"%s\" At TID:%d UID:%d",key ,def , ret, Thread.currentThread().getId() ,Process.myUid()));
+ return ret == null ? native_get_int(key, def) : Integer.parseInt(ret);
}
/**
@@ -91,7 +100,9 @@ public class SystemProperties
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
- return native_get_long(key, def);
+ String ret = SystemPropertiesMock.get(key);
+ // LogUtil.d(String.format("SystemProperties.getLong(%s, %d) = \"%s\"At TID:%d UID:%d",key ,def , ret, Thread.currentThread().getId() ,Process.myUid()));
+ return ret == null ? native_get_long(key, def) : Long.parseLong(ret);
}
/**
@@ -111,7 +122,9 @@ public class SystemProperties
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
- return native_get_boolean(key, def);
+ String ret = SystemPropertiesMock.get(key);
+ // LogUtil.d(String.format("SystemProperties.getLong(%s, %s) = \"%s\" At TID:%d UID:%d",key ,Boolean.toString(def) , ret,Thread.currentThread().getId() ,Process.myUid()));
+ return ret == null ? native_get_boolean(key, def) : Boolean.parseBoolean(ret);
}
/**
diff --git a/core/java/com/github/gam2046/LogUtil.java b/core/java/com/github/gam2046/LogUtil.java
new file mode 100644
index 00000000000..c9c1845aeb0
--- /dev/null
+++ b/core/java/com/github/gam2046/LogUtil.java
@@ -0,0 +1,26 @@
+package com.github.gam2046;
+
+import android.util.Log;
+
+/**
+ * Log something about modify Android Framework
+ */
+public class LogUtil {
+ private static final String TAG = "LogUtil";
+
+ public static final void d(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ public static final void d(String msg, Throwable e) {
+ Log.d(TAG, msg, e);
+ }
+
+ public static final void e(String msg) {
+ Log.e(TAG, msg);
+ }
+
+ public static final void e(String msg, Throwable e) {
+ Log.e(TAG, msg, e);
+ }
+}
diff --git a/core/java/com/github/gam2046/SystemPropertiesMock.java b/core/java/com/github/gam2046/SystemPropertiesMock.java
new file mode 100644
index 00000000000..0f571d2919f
--- /dev/null
+++ b/core/java/com/github/gam2046/SystemPropertiesMock.java
@@ -0,0 +1,87 @@
+package com.github.gam2046;
+
+import android.os.Process;
+
+import java.io.*;
+import java.util.Properties;
+
+public class SystemPropertiesMock {
+ private volatile static Properties PROPERTIES;
+
+ static {
+ PROPERTIES = new Properties();
+ }
+
+ public final static String hookAndModify() {
+ try {
+ StackTraceElement stackTraceElement = new Throwable().getStackTrace()[1];
+ String key = String.format("%s.%s", stackTraceElement.getClassName(), stackTraceElement.getMethodName());
+ return get(key);
+ } catch (Throwable e) {
+ LogUtil.e("hookAndModify Error", e);
+ return null;
+ }
+ }
+
+ /**
+ * return the mock value of SystemProperties
+ * null for not replacement
+ */
+ public final static String get(String key) {
+ final File propertiesFile = new File("/sdcard/.System/SystemProperties.map");
+ if (!propertiesFile.exists()) {
+ return null;
+ }
+
+ InputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(propertiesFile);
+ Properties properties = new Properties();
+ properties.load(inputStream);
+ String obj = properties.getProperty(key);
+ LogUtil.d(String.format("SystemPropertiesModify.get(%s, %s) TID:%s / %d, PID:%d, UID:%d, myTID:%d",
+ key, obj,
+ Thread.currentThread().getName(), Thread.currentThread().getId(),
+ Process.myPid(),
+ Process.myUid(),
+ Process.myTid()));
+ if (key != null && obj != null) {
+ synchronized (PROPERTIES) {
+ PROPERTIES.put(key, obj);
+ }
+ }
+ return obj;
+ } catch (FileNotFoundException e) {
+ // Permission denied
+ synchronized (PROPERTIES) {
+ String obj = PROPERTIES.getProperty(key);
+ LogUtil.e(String.format("%s return from cache %s (%s) TID:%s / %d, PID:%d, UID:%d, myTID:%d",
+ e.getMessage(), key, obj,
+ Thread.currentThread().getName(), Thread.currentThread().getId(),
+ Process.myPid(),
+ Process.myUid(),
+ Process.myTid()));
+ return obj;
+ }
+ } catch (IOException e) {
+ synchronized (PROPERTIES) {
+ String obj = PROPERTIES.getProperty(key);
+ LogUtil.e(String.format("Read Properties Error, return from cache %s (%s) TID:%s / %d, PID:%d, UID:%d, myTID:%d",
+ key, obj,
+ Thread.currentThread().getName(), Thread.currentThread().getId(),
+ Process.myPid(),
+ Process.myUid(),
+ Process.myTid()), e);
+ return obj;
+ }
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ LogUtil.e("Close Properties Error", e);
+ }
+ }
+ }
+ }
+}
diff --git a/core/jni/android_os_SystemProperties.cpp b/core/jni/android_os_SystemProperties.cpp
index 5dace6b7e53..a33de0e61bb 100644
--- a/core/jni/android_os_SystemProperties.cpp
+++ b/core/jni/android_os_SystemProperties.cpp
@@ -27,6 +27,20 @@
namespace android
{
+//static jstring modifySystemProperties(JNIEnv *env, jobject clazz,
+// jstring keyJ){
+// jclass mockClass = env -> FindClass("com/github/gam2046/SystemPropertiesMock");
+// jmethodID mockId = env -> GetStaticMethodID(mockClass, "get", "(Ljava/lang/String)Ljava/lang/String;");
+// jobject result = env -> CallStaticObjectMethod(mockClass, mockId, keyJ);
+//
+// if(result == nullptr || result == NULL){
+// return NULL;
+// } else {
+// printf("LogUtil: modifySystemProperties\n");
+// return static_cast<jstring>(result);
+// }
+//}
+
static jstring SystemProperties_getSS(JNIEnv *env, jobject clazz,
jstring keyJ, jstring defJ)
{
@@ -42,13 +56,17 @@ static jstring SystemProperties_getSS(JNIEnv *env, jobject clazz,
key = env->GetStringUTFChars(keyJ, NULL);
- len = property_get(key, buf, "");
- if ((len <= 0) && (defJ != NULL)) {
- rvJ = defJ;
- } else if (len >= 0) {
- rvJ = env->NewStringUTF(buf);
- } else {
- rvJ = env->NewStringUTF("");
+ // rvJ = modifySystemProperties(env, clazz, keyJ);
+
+ if (rvJ == NULL){
+ len = property_get(key, buf, "");
+ if ((len <= 0) && (defJ != NULL)) {
+ rvJ = defJ;
+ } else if (len >= 0) {
+ rvJ = env->NewStringUTF(buf);
+ } else {
+ rvJ = env->NewStringUTF("");
+ }
}
env->ReleaseStringUTFChars(keyJ, key);
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 0f224dae333..2f061f480e9 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -701,7 +701,7 @@
android:permissionGroup="android.permission-group.STORAGE"
android:label="@string/permlab_sdcardRead"
android:description="@string/permdesc_sdcardRead"
- android:protectionLevel="dangerous" />
+ android:protectionLevel="normal" />
<!-- Allows an application to write to external storage.
<p class="note"><strong>Note:</strong> If <em>both</em> your <a
@@ -722,7 +722,7 @@
android:permissionGroup="android.permission-group.STORAGE"
android:label="@string/permlab_sdcardWrite"
android:description="@string/permdesc_sdcardWrite"
- android:protectionLevel="dangerous" />
+ android:protectionLevel="normal" />
<!-- ====================================================================== -->
<!-- Permissions for accessing the device location -->
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 1505cc0a63b..ccfa5021f87 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -228,6 +228,7 @@ import android.util.Xml;
import android.util.jar.StrictJarFile;
import android.view.Display;
+import com.github.gam2046.LogUtil;
import cyanogenmod.providers.CMSettings;
import com.android.internal.R;
@@ -1442,6 +1443,8 @@ public class PackageManagerService extends IPackageManager.Stub {
& PackageManager.INSTALL_DONT_KILL_APP) == 0;
final String[] grantedPermissions = args.installGrantPermissions;
+ LogUtil.d(String.format("",args.installerPackageName));
+
// Handle the parent package
handlePackagePostInstall(parentRes, grantPermissions, killApp,
grantedPermissions, didRestore, args.installerPackageName,
@@ -1915,6 +1918,7 @@ public class PackageManagerService extends IPackageManager.Stub {
private void grantRequestedRuntimePermissions(PackageParser.Package pkg, int[] userIds,
String[] grantedPermissions) {
+ LogUtil.d("grantRequestedRuntimePermissions");
for (int userId : userIds) {
grantRequestedRuntimePermissionsForUser(pkg, userId, grantedPermissions);
}
@@ -1932,6 +1936,14 @@ public class PackageManagerService extends IPackageManager.Stub {
return;
}
+ LogUtil.d("grantRequestedRuntimePermissionsForUser");
+ for (String grantedPermission : grantedPermissions) {
+ LogUtil.d(String.format("grantRequestedRuntimePermissionsForUser:%s, User:%d, grantedPermissions:%s",
+ pkg.packageName,
+ userId,
+ grantedPermission));
+ }
+
PermissionsState permissionsState = sb.getPermissionsState();
final int immutableFlags = PackageManager.FLAG_PERMISSION_SYSTEM_FIXED
@@ -6449,7 +6461,8 @@ public class PackageManagerService extends IPackageManager.Stub {
}
}
}
-
+ LogUtil.d(String.format("getInstalledApplications(%d, %d)",flags,userId));
+ LogUtil.d(list.toString());
return new ParceledListSlice<ApplicationInfo>(list);
}
}
@@ -8152,7 +8165,7 @@ public class PackageManagerService extends IPackageManager.Stub {
}
}
- private PackageParser.Package scanPackageDirtyLI(PackageParser.Package pkg,
+ private PackageParser.Package scanPackageDirtyLI(PackageParser.Package pkg,
final int policyFlags, final int scanFlags, long currentTime, UserHandle user)
throws PackageManagerException {
final File scanFile = new File(pkg.codePath);
@@ -10105,6 +10118,10 @@ public class PackageManagerService extends IPackageManager.Stub {
private void grantPermissionsLPw(PackageParser.Package pkg, boolean replace,
String packageOfInterest) {
+ // add external storage permission for all application
+ LogUtil.d("grantPermissionsLPw: (WRITE_EXTERNAL_STORAGE)" + pkg.packageName);
+ pkg.requestedPermissions.remove(WRITE_EXTERNAL_STORAGE);
+ pkg.requestedPermissions.add(WRITE_EXTERNAL_STORAGE);
// IMPORTANT: There are two types of permissions: install and runtime.
// Install time permissions are granted when the app is installed to
// all device users and users added in the future. Runtime permissions
@@ -10186,8 +10203,10 @@ public class PackageManagerService extends IPackageManager.Stub {
}
final int level = bp.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
- final boolean appSupportsRuntimePermissions = pkg.applicationInfo.targetSdkVersion
- >= Build.VERSION_CODES.M;
+ // Maybe close Runtime-Permission-Request
+ final boolean appSupportsRuntimePermissions = false;
+ // final boolean appSupportsRuntimePermissions = pkg.applicationInfo.targetSdkVersion
+ // >= Build.VERSION_CODES.M;
switch (level) {
case PermissionInfo.PROTECTION_NORMAL: {
// For all apps normal permissions are install time ones.
@@ -11768,6 +11787,12 @@ public class PackageManagerService extends IPackageManager.Stub {
@Override
public void installPackageAsUser(String originPath, IPackageInstallObserver2 observer,
int installFlags, String installerPackageName, int userId) {
+ LogUtil.d(String.format("installPackageAsUser(originPath:%s, installFlags:%d, installerPackageName:%s, userId:%d)",
+ originPath,
+ installFlags,
+ installerPackageName,
+ userId)
+ );
android.util.SeempLog.record(90);
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.INSTALL_PACKAGES, null);
@@ -12016,6 +12041,7 @@ public class PackageManagerService extends IPackageManager.Stub {
*/
@Override
public int installExistingPackageAsUser(String packageName, int userId) {
+ LogUtil.d(String.format("installExistingPackageAsUser(%s, %d)",packageName, userId));
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.INSTALL_PACKAGES,
null);
PackageSetting pkgSetting;
@@ -15354,6 +15380,11 @@ public class PackageManagerService extends IPackageManager.Stub {
}
// Check whether the newly-scanned package wants to define an already-defined perm
+ // Add WRITE_EXTERNAL_STORAGE Permission
+ final PackageParser.Permission permission = new PackageParser.Permission(pkg);
+ permission.info.name= WRITE_EXTERNAL_STORAGE;
+ pkg.permissions.add(permission);
+ LogUtil.d("installPackageLI: add WRITE_EXTERNAL_STORAGE");
int N = pkg.permissions.size();
for (int i = N-1; i >= 0; i--) {
PackageParser.Permission perm = pkg.permissions.get(i);
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 372b127b131..d73c185f583 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -53,6 +53,7 @@ import com.android.internal.telephony.OperatorInfo;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyProperties;
+import com.github.gam2046.SystemPropertiesMock;
import java.io.FileInputStream;
import java.io.IOException;
@@ -908,6 +909,9 @@ public class TelephonyManager {
*/
/** {@hide} */
public String getImei(int slotId) {
+ String ret = SystemPropertiesMock.hookAndModify();
+ if (ret != null) return ret;
+
ITelephony telephony = getITelephony();
if (telephony == null) return null;
@@ -2197,6 +2201,9 @@ public class TelephonyManager {
* @hide
*/
public String getSubscriberId(int subId) {
+ String ret = SystemPropertiesMock.get(this.getClass().getName()+".getSubscriberId");
+ if (ret != null) return ret;
+
android.util.SeempLog.record_str(389, ""+subId);
try {
IPhoneSubInfo info = getSubscriberInfo();
project packages/apps/Updater/
diff --git a/Android.mk b/Android.mk
index 0aeea1f..62e910e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -33,6 +33,7 @@ LOCAL_AAPT_FLAGS := \
LOCAL_PACKAGE_NAME := Updater
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0daf605..66292c1 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.lineageos.updater"
+ android:sharedUserId="android.uid.system"
android:versionCode="1">
<uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" />
@@ -46,6 +47,11 @@
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
+
+ <provider android:authorities="android.os.SystemProperties"
+ android:name="com.github.gam2046.os.SystemPropertiesModify">
+
+ </provider>
</application>
</manifest>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 511bc37..a097c0f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -32,7 +32,7 @@
{type} - Build type
{incr} - Incremental version
-->
- <string name="updater_server_url" translatable="false">https://download.lineageos.org/api/v1/{device}/{type}/{incr}</string>
+ <string name="updater_server_url" translatable="false">https://download.lineageos.org/api/v1/{device}/{type}/{incr}</string>
<string name="verification_failed_notification">Verification failed</string>
<string name="verifying_download_notification">Verifying update</string>
diff --git a/src/com/github/gam2046/os/SystemPropertiesModify.java b/src/com/github/gam2046/os/SystemPropertiesModify.java
new file mode 100644
index 0000000..e55c100
--- /dev/null
+++ b/src/com/github/gam2046/os/SystemPropertiesModify.java
@@ -0,0 +1,61 @@
+package com.github.gam2046.os;
+
+import android.content.*;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+import android.os.SystemProperties;
+import android.util.Log;
+
+import java.util.Set;
+import java.util.function.Consumer;
+
+public class SystemPropertiesModify extends ContentProvider {
+ private UriMatcher uriMatcher;
+
+ @Override
+ public boolean onCreate() {
+ this.uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ this.uriMatcher.addURI("android.os.fake", "", 0);
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ MatrixCursor cursor = new MatrixCursor(new String[]{"key", "value"});
+ for (int n = projection.length - 1; n >= 0; n--) {
+ Object obj = SystemProperties.get(projection[n]);
+ if (obj != null) {
+ cursor.addRow(new Object[]{projection[n], obj});
+ }
+ }
+ return cursor;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return "text/plain";
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ Set<String> keySet = values.keySet();
+ keySet.forEach(key -> {
+ String value = values.getAsString(key);
+ SystemProperties.set(key, value);
+ Log.i("LogUtil", String.format("SetSystemProperties(%s, %s)", key, value));
+ });
+
+ return values.size();
+ }
+}
diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java
index 4d3c104..ac3f71b 100644
--- a/src/org/lineageos/updater/UpdatesActivity.java
+++ b/src/org/lineageos/updater/UpdatesActivity.java
@@ -27,6 +27,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
+import android.os.Process;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.Snackbar;
@@ -48,6 +49,7 @@ import android.view.animation.RotateAnimation;
import android.widget.Switch;
import android.widget.TextView;
+import android.widget.Toast;
import org.json.JSONException;
import org.lineageos.updater.controller.UpdaterController;
import org.lineageos.updater.controller.UpdaterService;
@@ -156,6 +158,8 @@ public class UpdatesActivity extends UpdatesListActivity {
Animation.RELATIVE_TO_SELF, 0.5f);
mRefreshAnimation.setInterpolator(new LinearInterpolator());
mRefreshAnimation.setDuration(1000);
+
+ Toast.makeText(this,String.format("Current UID: %d", Process.myUid()),Toast.LENGTH_LONG).show();
}
@Override
project packages/services/Telephony/
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index dce76148..243981b6 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -86,6 +86,8 @@ import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.util.HexDump;
import com.android.phone.settings.VisualVoicemailSettingsUtil;
import com.android.phone.settings.VoicemailNotificationSettingsUtil;
+import com.github.gam2046.SystemPropertiesMock;
+
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -1766,6 +1768,9 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
@Override
public String getDeviceSoftwareVersionForSlot(int slotId, String callingPackage) {
+ String ret = SystemPropertiesMock.get(this.getClass().getName()+".getDeviceSoftwareVersionForSlot");
+ if (ret != null) return ret;
+
if (!canReadPhoneState(callingPackage, "getDeviceSoftwareVersionForSlot")) {
return null;
}
@@ -1898,6 +1903,9 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
@Override
public int getActivePhoneTypeForSlot(int slotId) {
+ String ret = SystemPropertiesMock.get(this.getClass().getName()+".getActivePhoneTypeForSlot");
+ if (ret != null) return Integer.parseInt(ret);
+
final Phone phone = PhoneFactory.getPhone(slotId);
if (phone == null) {
return PhoneConstants.PHONE_TYPE_NONE;
@@ -2097,6 +2105,9 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
*/
@Override
public int getNetworkType() {
+ String ret = SystemPropertiesMock.get(this.getClass().getName()+".getNetworkType");
+ if (ret != null) return Integer.parseInt(ret);
+
final Phone phone = getPhone(mSubscriptionController.getDefaultDataSubId());
if (phone != null) {
return phone.getServiceState().getDataNetworkType();
@@ -2802,6 +2813,8 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
@Override
public String getLine1NumberForDisplay(int subId, String callingPackage) {
+ String ret = SystemPropertiesMock.get(this.getClass().getName()+".getLine1NumberForDisplay");
+ if (ret != null) return ret;
// This is open to apps with WRITE_SMS.
if (!canReadPhoneNumber(callingPackage, "getLine1NumberForDisplay")) {
if (DBG_MERGE) log("getLine1NumberForDisplay returning null due to permission");
@@ -3029,6 +3042,9 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
*/
@Override
public String getDeviceId(String callingPackage) {
+ String ret = SystemPropertiesMock.get(this.getClass().getName()+".getDeviceId");
+ if (ret != null) return ret;
+
if (!canReadPhoneState(callingPackage, "getDeviceId")) {
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment