一生の間、私はこれを見つけることができません。考え出したと思ったけど
以下の項目を含むXMLファイルがあります。
<compat-change description="Flag {@link android.content.Context#BIND_INCLUDE_CAPABILITIES} is used to pass while-in-use capabilities from client process to bound service. In targetSdkVersion R and above, if client is a TOP activity, when this flag is present, bound service gets all while-in-use capabilities; when this flag is not present, bound service gets no while-in-use capability from client." enableAfterTargetSdk="29" id="136274596" name="PROCESS_CAPABILITY_CHANGE_ID"/>
IDと名前(常に静的値と同じ順序)を一致させる必要がありますが、Sdk値(変更可能)を変更する必要があります。
Sdk="29" id="136274596" name="PROCESS_CAPABILITY"
頑張った
sed -i '/Sdk=\"[0-9]\+\".*id="143937733".*name="PROCESS_CAPABILITY"/ {s/Sdk=\"[0-9]\+\"/Sdk=\"0\"/1;}'
どんな提案でも大変感謝します。
答え1
xmlstarlet
次の適切なXMLツールを使用することをお勧めします。
xmlstarlet ed -u '
//compat-change[@id="136274596"][starts-with(@name,"PROCESS_CAPABILITY")]/@enableAfterTargetSdk
' -v 0 file.xml
前任者。
$ xmlstarlet ed -u '//compat-change[@id="136274596"][starts-with(@name,"PROCESS_CAPABILITY")]/@enableAfterTargetSdk' -v 0 file.xml
<?xml version="1.0"?>
<compat-change description="Flag {@link android.content.Context#BIND_INCLUDE_CAPABILITIES} is used to pass while-in-use capabilities from client process to bound service. In targetSdkVersion R and above, if client is a TOP activity, when this flag is present, bound service gets all while-in-use capabilities; when this flag is not present, bound service gets no while-in-use capability from client." enableAfterTargetSdk="0" id="136274596" name="PROCESS_CAPABILITY_CHANGE_ID"/>
答え2
使用sed
$ sed -E 's/(Sdk=")[^"]*(" id="136274596" name="PROCESS_CAPABILITY)/\10\2/' input_file
<compat-change description="Flag {@link android.content.Context#BIND_INCLUDE_CAPABILITIES} is used to pass while-in-use capabilities from client process to bound service. In targetSdkVersion R and above, if client is a TOP activity, when this flag is present, bound service gets all while-in-use capabilities; when this flag is not present, bound service gets no while-in-use capability from client." enableAfterTargetSdk="0" id="136274596" name="PROCESS_CAPABILITY_CHANGE_ID"/>