unsetting persistent system properties

2019-02-01 02:07发布

问题:

I can set a persistent system property on an Android phone (with appropriate permissions) using setprop <key> <value> command:

$ adb shell setprop persist.this.is.my.property testing

I can then confirm that the property was set:

$ adb shell getprop persist.this.is.my.property
testing

But I can't remove the key now that it is set (because of the persist at the start of the key it is there after the phone reboots). There is no unsetprop or rmprop or anything similar. Attempting to set the value to nil or null sets that to the value and leaving it empty prompts the help instructions.

Does anyone know how to unset a system property from the command line after it has been set?

回答1:

To remove the property:

rm /data/property/persist.this.is.my.property && reboot


回答2:

You can remove the property with adb shell setprop persist.this.is.my.property ""



回答3:

It works for me.
on macOS:
echo -e "setprop wrap.$PACKAGE_NAME \"\"\n exit" > .temp adb shell < .temp rm ./.temp

on android:
setprop wrap.$PACKAGE_NAME ""



回答4:

adb shell setprop persist.this.is.my.property \"\"
adb shell reboot

Changed the property value so it wouldn't be using it's previous value.
Empty quotes("") wouldnt work for me, I had to escape them(this is in bash).



回答5:

Just reboot the device, the property will unset.