project device/generic/car/ diff --git a/common/car.mk b/common/car.mk index 5fea1f7..4579924 100644 --- a/common/car.mk +++ b/common/car.mk @@ -55,7 +55,8 @@ PRODUCT_COPY_FILES += \ # Enable landscape PRODUCT_COPY_FILES += \ - frameworks/native/data/etc/android.hardware.screen.landscape.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.screen.landscape.xml + frameworks/native/data/etc/android.hardware.screen.landscape.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.screen.landscape.xml \ + frameworks/native/data/etc/android.hardware.screen.portrait.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.screen.portrait.xml # Used to embed a map in an activity view PRODUCT_COPY_FILES += \ project device/lineage/car/ diff --git a/lineage_car.mk b/lineage_car.mk index a0a52b1..2c98b75 100644 --- a/lineage_car.mk +++ b/lineage_car.mk @@ -3,4 +3,5 @@ PRODUCT_PACKAGES += \ CarSettingsProviderOverlay PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \ + config.override_forced_orient=true \ persist.bluetooth.enablenewavrcp=false \ project device/lineage/sepolicy/ diff --git a/common/private/adbroot.te b/common/private/adbroot.te index de201a6..828ce90 100644 --- a/common/private/adbroot.te +++ b/common/private/adbroot.te @@ -7,6 +7,9 @@ binder_use(adbroot) binder_service(adbroot) add_service(adbroot, adbroot_service) +allow adbroot package_native_service:service_manager find; +binder_call(adbroot, system_server) + allow adbroot adbroot_data_file:dir rw_dir_perms; allow adbroot adbroot_data_file:file create_file_perms; project device/samsung/gta4xlwifi/ diff --git a/lineage_gta4xlwifi.mk b/lineage_gta4xlwifi.mk index d2098bb..45c7dc4 100644 --- a/lineage_gta4xlwifi.mk +++ b/lineage_gta4xlwifi.mk @@ -27,7 +27,18 @@ TARGET_SCREEN_HEIGHT := 2000 TARGET_SCREEN_WIDTH := 1200 ## Inherit some common Lineage stuff -$(call inherit-product, vendor/lineage/config/common_full_tablet_wifionly.mk) +# $(call inherit-product, vendor/lineage/config/common_full_tablet_wifionly.mk) +TARGET_DISABLE_EPPE := true +$(call inherit-product, vendor/lineage/config/common_car.mk) +$(call inherit-product, device/lineage/car/lineage_car_vendor.mk) + +PRODUCT_PRODUCT_PROPERTIES += \ + persist.adb.tcp.port=5555 \ + persist.service.adb.enable=1 \ + persist.service.debuggable=1 \ + persist.sys.usb.config=mtp,adb \ + ro.secure=0 \ + ro.adb.secure=0 ## Enable updating of APEXes $(call inherit-product, $(SRC_TARGET_DIR)/product/updatable_apex.mk) project frameworks/base/ diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index 99b15db780dc..e94c3b19e7d2 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -28,7 +28,7 @@ 0 true true - false + true 102 false project packages/modules/adb/ diff --git a/Android.bp b/Android.bp index 0a808e9d..427b6e7b 100644 --- a/Android.bp +++ b/Android.bp @@ -800,9 +800,12 @@ cc_binary { ], shared_libs: [ "libbase", + "libbinder", "libbinder_ndk", + "libcutils", "liblog", "libutils", + "packagemanager_aidl-cpp", ], static_libs: [ "adbroot_aidl_interface-ndk", diff --git a/root/adbroot_service.cpp b/root/adbroot_service.cpp index 710a521e..287e47a8 100644 --- a/root/adbroot_service.cpp +++ b/root/adbroot_service.cpp @@ -15,10 +15,14 @@ */ #include +#include #include #include #include #include +#include +#include +#include #include #include "adbroot_service.h" @@ -33,6 +37,32 @@ static ndk::ScopedAStatus SecurityException(const std::string& msg) { } } // anonymous namespace +namespace android { +static bool isAutomotive() { + sp serviceManager = defaultServiceManager(); + if (serviceManager.get() == nullptr) { + LOG(ERROR) << "Unable to access native ServiceManager"; + return false; + } + sp packageManager; + sp binder = serviceManager->waitForService(String16("package_native")); + packageManager = interface_cast(binder); + if (packageManager == nullptr) { + LOG(ERROR) << "Unable to access native PackageManager"; + return false; + } + bool isAutomotive = false; + binder::Status status = + packageManager->hasSystemFeature(String16("android.hardware.type.automotive"), 0, + &isAutomotive); + if (!status.isOk()) { + LOG(ERROR) << "Calling hasSystemFeature failed: " << status.exceptionMessage().c_str(); + return false; + } + return isAutomotive; +} +} // namespace android + namespace aidl { namespace android { namespace adbroot { @@ -43,6 +73,11 @@ using ::android::base::SetProperty; using ::android::base::Trim; using ::android::base::WriteStringToFile; +static inline bool isAutomotive(uid_t uid) { + appid_t appid = multiuser_get_app_id(uid); + return appid == AID_SYSTEM && ::android::isAutomotive(); +} + ADBRootService::ADBRootService() : enabled_(false) { std::string buf; if (ReadFileToString(kStoragePath + kEnabled, &buf)) { @@ -62,7 +97,7 @@ void ADBRootService::Register() { ndk::ScopedAStatus ADBRootService::isSupported(bool* _aidl_return) { uid_t uid = AIBinder_getCallingUid(); - if (uid != AID_SYSTEM && uid != AID_SHELL) { + if (uid != AID_SYSTEM && uid != AID_SHELL && !isAutomotive(uid)) { return SecurityException("Caller must be system or shell"); } @@ -73,7 +108,7 @@ ndk::ScopedAStatus ADBRootService::isSupported(bool* _aidl_return) { ndk::ScopedAStatus ADBRootService::setEnabled(bool enabled) { uid_t uid = AIBinder_getCallingUid(); - if (uid != AID_SYSTEM) { + if (uid != AID_SYSTEM && !isAutomotive(uid)) { return SecurityException("Caller must be system"); } @@ -95,7 +130,7 @@ ndk::ScopedAStatus ADBRootService::setEnabled(bool enabled) { ndk::ScopedAStatus ADBRootService::getEnabled(bool* _aidl_return) { uid_t uid = AIBinder_getCallingUid(); - if (uid != AID_SYSTEM && uid != AID_SHELL) { + if (uid != AID_SYSTEM && uid != AID_SHELL && !isAutomotive(uid)) { return SecurityException("Caller must be system or shell"); }