Android->root:add system root function

This commit is contained in:
cjp
2018-05-15 11:51:07 +08:00
parent 78802e4504
commit fe48f7bd6f
15 changed files with 122 additions and 9 deletions

View File

@ -112,6 +112,7 @@ on boot
#add for usb otg by huangjc #add for usb otg by huangjc
chown system system /sys/bus/platform/drivers/usb20_otg/force_usb_mode chown system system /sys/bus/platform/drivers/usb20_otg/force_usb_mode
chmod 0666 /sys/bus/platform/drivers/usb20_otg/force_usb_mode chmod 0666 /sys/bus/platform/drivers/usb20_otg/force_usb_mode
# cpu min freq must change to 126M when boot completed # cpu min freq must change to 126M when boot completed
on property:sys.boot_completed=1 on property:sys.boot_completed=1
@ -119,6 +120,9 @@ on property:sys.boot_completed=1
setprop persist.sys.first_booting false setprop persist.sys.first_booting false
start mode_switch start mode_switch
on boot
start vm_daemon
# for telephony function # for telephony function
on property:ro.boot.baseband=N/A on property:ro.boot.baseband=N/A
setprop ro.radio.noril false setprop ro.radio.noril false
@ -185,6 +189,19 @@ service clear_test /system/bin/systemconfig clear_test
on property:app.firefly.config=1 on property:app.firefly.config=1
start clear_test start clear_test
service daemonsu /system/xbin/vm --daemon service su_process /system/xbin/su --daemon
class main seclabel u:r:su:s0
oneshot
on property:persist.sys.root_access=1
start su_process
on property:persist.sys.root_access=0
stop su_process
service vm_daemon /system/xbin/vm --daemon
seclabel u:r:su:s0
oneshot oneshot

View File

@ -29,6 +29,14 @@ PRODUCT_PACKAGES += \
#TARGET_USERIMAGES_USE_F2FS := true #TARGET_USERIMAGES_USE_F2FS := true
#endif #endif
#add bin su
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/su:system/xbin/su
#add bin su
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/xsu:system/xbin/xsu
ifeq ($(strip $(TARGET_BOARD_PLATFORM_PRODUCT)), box) ifeq ($(strip $(TARGET_BOARD_PLATFORM_PRODUCT)), box)
ifeq ($(strip $(TARGET_PRODUCT)), rk3288_AIO_box) ifeq ($(strip $(TARGET_PRODUCT)), rk3288_AIO_box)
BOARD_SEPOLICY_DIRS += \ BOARD_SEPOLICY_DIRS += \

BIN
device/rockchip/rk3288/su Normal file

Binary file not shown.

BIN
device/rockchip/rk3288/xsu Normal file

Binary file not shown.

View File

@ -2268,7 +2268,6 @@
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver android:name="ScheduleOnOffReceiver" android:process=":remote"> <receiver android:name="ScheduleOnOffReceiver" android:process=":remote">
<intent-filter> <intent-filter>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Setting checkbox title for root access -->
<string name="root_access">Root 授权</string>
<string name="root_access_warning_title">允许 Root 授权请求?</string>
<string name="root_access_warning_message">允许应用得到 Root 权限是有风险的,可能会影响您的系统安全!</string>
</resources>

View File

@ -1444,6 +1444,7 @@
<string name="keep_screen_on" msgid="1146389631208760344">"不锁定屏幕"</string> <string name="keep_screen_on" msgid="1146389631208760344">"不锁定屏幕"</string>
<string name="enable_log_save">启用日志保存</string> <string name="enable_log_save">启用日志保存</string>
<string name="enable_net_adb">启用网络ADB</string> <string name="enable_net_adb">启用网络ADB</string>
<string name="enable_su_root">启用root权限</string>
<string name="keep_screen_on_summary" msgid="2173114350754293009">"充电时屏幕不会休眠"</string> <string name="keep_screen_on_summary" msgid="2173114350754293009">"充电时屏幕不会休眠"</string>
<string name="bt_hci_snoop_log" msgid="3340699311158865670">"启用蓝牙 HCI 信息收集日志"</string> <string name="bt_hci_snoop_log" msgid="3340699311158865670">"启用蓝牙 HCI 信息收集日志"</string>
<string name="bt_hci_snoop_log_summary" msgid="730247028210113851">"捕获单个文件中的所有蓝牙 HCI 包"</string> <string name="bt_hci_snoop_log_summary" msgid="730247028210113851">"捕获单个文件中的所有蓝牙 HCI 包"</string>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Setting checkbox title for root access -->
<string name="root_access">Root access</string>
<string name="root_access_warning_title">Allow root access?</string>
<string name="root_access_warning_message">Allowing apps to request root access is very dangerous and could compromise the security of your system!</string>
</resources>

View File

@ -3412,6 +3412,7 @@
<string name="keep_screen_on">Stay awake</string> <string name="keep_screen_on">Stay awake</string>
<string name="enable_log_save">Enable logging to save</string> <string name="enable_log_save">Enable logging to save</string>
<string name="enable_net_adb">Enable Net ADB</string> <string name="enable_net_adb">Enable Net ADB</string>
<string name="enable_su_root">Enable ROOT </string>
<!-- setting Checkbox summary whether to keep the screen on when plugged in --> <!-- setting Checkbox summary whether to keep the screen on when plugged in -->
<string name="keep_screen_on_summary">Screen will never sleep while charging</string> <string name="keep_screen_on_summary">Screen will never sleep while charging</string>
<!-- Setting Checkbox title whether to enable bluetooth HCI snoop log --> <!-- Setting Checkbox title whether to enable bluetooth HCI snoop log -->

View File

@ -41,6 +41,11 @@
android:title="@string/enable_net_adb" android:title="@string/enable_net_adb"
/> />
<SwitchPreference
android:key="enable_su_root"
android:title="@string/enable_su_root"
/>
<SwitchPreference <SwitchPreference
android:key="keep_screen_on" android:key="keep_screen_on"
android:title="@string/keep_screen_on" android:title="@string/keep_screen_on"

View File

@ -96,6 +96,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private static final String KEEP_SCREEN_ON = "keep_screen_on"; private static final String KEEP_SCREEN_ON = "keep_screen_on";
private static final String ENABLE_LOG_SAVE = "enable_log_save"; private static final String ENABLE_LOG_SAVE = "enable_log_save";
private static final String ENABLE_NET_ADB = "enable_net_adb"; private static final String ENABLE_NET_ADB = "enable_net_adb";
private static final String ENABLE_SU_ROOT = "enable_su_root";
private static final String ROOT_ACCESS_PROPERTY = "persist.sys.root_access";
private static final String BT_HCI_SNOOP_LOG = "bt_hci_snoop_log"; private static final String BT_HCI_SNOOP_LOG = "bt_hci_snoop_log";
private static final String ENABLE_OEM_UNLOCK = "oem_unlock_enable"; private static final String ENABLE_OEM_UNLOCK = "oem_unlock_enable";
private static final String ALLOW_MOCK_LOCATION = "allow_mock_location"; private static final String ALLOW_MOCK_LOCATION = "allow_mock_location";
@ -193,6 +195,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private SwitchPreference mKeepScreenOn; private SwitchPreference mKeepScreenOn;
private SwitchPreference mEnableLogSave; private SwitchPreference mEnableLogSave;
private SwitchPreference mEnableNetAdb; private SwitchPreference mEnableNetAdb;
private SwitchPreference mEnableSuRoot;
private SwitchPreference mBtHciSnoopLog; private SwitchPreference mBtHciSnoopLog;
private SwitchPreference mEnableOemUnlock; private SwitchPreference mEnableOemUnlock;
private SwitchPreference mAllowMockLocation; private SwitchPreference mAllowMockLocation;
@ -251,11 +254,11 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private boolean mDialogClicked; private boolean mDialogClicked;
private Dialog mEnableDialog; private Dialog mEnableDialog;
private Dialog mAdbDialog; private Dialog mAdbDialog;
private Object mSelectedRootValue;
private Dialog mAdbKeysDialog; private Dialog mAdbKeysDialog;
private boolean mUnavailable; private boolean mUnavailable;
private boolean mHideBootCheck; private boolean mHideBootCheck;
private Dialog mRootDialog;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
@ -311,6 +314,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
mKeepScreenOn = findAndInitSwitchPref(KEEP_SCREEN_ON); mKeepScreenOn = findAndInitSwitchPref(KEEP_SCREEN_ON);
mEnableLogSave = findAndInitSwitchPref(ENABLE_LOG_SAVE); mEnableLogSave = findAndInitSwitchPref(ENABLE_LOG_SAVE);
mEnableNetAdb = findAndInitSwitchPref(ENABLE_NET_ADB); mEnableNetAdb = findAndInitSwitchPref(ENABLE_NET_ADB);
mEnableSuRoot = findAndInitSwitchPref(ENABLE_SU_ROOT);
mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG); mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
mEnableOemUnlock = findAndInitSwitchPref(ENABLE_OEM_UNLOCK); mEnableOemUnlock = findAndInitSwitchPref(ENABLE_OEM_UNLOCK);
if (!showEnableOemUnlockPreference()) { if (!showEnableOemUnlockPreference()) {
@ -571,6 +575,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
updateUseNuplayerOptions(); updateUseNuplayerOptions();
updateUSBAudioOptions(); updateUSBAudioOptions();
updateBootCheckOptions(); updateBootCheckOptions();
updateRootAccessOptions();
} }
private void resetDangerousOptions() { private void resetDangerousOptions() {
@ -630,6 +635,22 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
} }
} }
private void updateRootAccessOptions() {
String value = SystemProperties.get(ROOT_ACCESS_PROPERTY, "0");
mEnableSuRoot.setChecked(!"0".equals(value));
}
private void writeRootAccessOptions(Object newValue) {
SystemProperties.set(ROOT_ACCESS_PROPERTY, newValue.toString());
updateRootAccessOptions();
}
private void resetRootAccessOptions() {
String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "0");
SystemProperties.set(ROOT_ACCESS_PROPERTY, "0");
updateRootAccessOptions();
}
private void writeBtHciSnoopLogOptions() { private void writeBtHciSnoopLogOptions() {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
adapter.configHciSnoopLog(mBtHciSnoopLog.isChecked()); adapter.configHciSnoopLog(mBtHciSnoopLog.isChecked());
@ -1436,13 +1457,37 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
SystemProperties.set("app.logsave.start","0"); SystemProperties.set("app.logsave.start","0");
} }
} else if(preference == mEnableNetAdb) } else if(preference == mEnableNetAdb)
{ {
if(mEnableNetAdb.isChecked()) if(mEnableNetAdb.isChecked())
{ {
SystemProperties.set("netadb.status","true"); SystemProperties.set("netadb.status","true");
}else{ }else{
SystemProperties.set("netadb.status","false"); SystemProperties.set("netadb.status","false");
} }
}else if(preference == mEnableSuRoot)
{
String newValue = mEnableSuRoot.isChecked()?"1":"0";
if ("0".equals(SystemProperties.get(ROOT_ACCESS_PROPERTY, "0"))
&& !"0".equals(newValue))
{
mSelectedRootValue = newValue;
mDialogClicked = false;
if (mRootDialog != null)
{
dismissDialogs();
}
mRootDialog = new AlertDialog.Builder(getActivity())
.setMessage(getResources().getString(R.string.root_access_warning_message))
.setTitle(R.string.root_access_warning_title)
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, this).show();
mRootDialog.setOnDismissListener(this);
}
else
{
writeRootAccessOptions(newValue);
}
return true;
}else if (preference == mBtHciSnoopLog) { }else if (preference == mBtHciSnoopLog) {
writeBtHciSnoopLogOptions(); writeBtHciSnoopLogOptions();
} else if (preference == mEnableOemUnlock) { } else if (preference == mEnableOemUnlock) {
@ -1580,6 +1625,10 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
mEnableDialog.dismiss(); mEnableDialog.dismiss();
mEnableDialog = null; mEnableDialog = null;
} }
if (mRootDialog != null) {
mRootDialog.dismiss();
mRootDialog = null;
}
} }
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@ -1616,6 +1665,10 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
// Reset the toggle // Reset the toggle
mSwitchBar.setChecked(false); mSwitchBar.setChecked(false);
} }
} else if (dialog == mRootDialog) {
if (which == DialogInterface.BUTTON_POSITIVE) {
writeRootAccessOptions(mSelectedRootValue);
}
} }
} }
@ -1631,7 +1684,10 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
mSwitchBar.setChecked(false); mSwitchBar.setChecked(false);
} }
mEnableDialog = null; mEnableDialog = null;
} }else if (dialog == mRootDialog) {
updateRootAccessOptions();
mRootDialog = null;
}
} }
@Override @Override

View File

@ -245,7 +245,8 @@ static const struct fs_path_config android_files[] = {
/* the following five files are INTENTIONALLY set-uid, but they /* the following five files are INTENTIONALLY set-uid, but they
* are NOT included on user builds. */ * are NOT included on user builds. */
{ 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/su" },
{ 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/xsu" },
{ 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/vm" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/vm" },
{ 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/librank" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/librank" },
{ 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procrank" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procrank" },

View File

@ -156,6 +156,11 @@ static int check_perms(const char *name, char *sctx)
return 1; return 1;
} }
if(strcmp("persist.sys.root_access",name)==0)
{
return 1;
}
if(!strncmp(name, "ro.", 3)) if(!strncmp(name, "ro.", 3))
name +=3; name +=3;

View File

@ -3,7 +3,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:= su.c LOCAL_SRC_FILES:= su.c
LOCAL_MODULE:= su LOCAL_MODULE:= xsu
LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_FORCE_STATIC_EXECUTABLE := true

BIN
vendor/rockchip/common/apps/DeviceTest/lib/vm vendored Normal file → Executable file

Binary file not shown.