tasks: find-sharedui-violation: Partition location
Allow for relocated partition directories in out, mainly for devices which do not possess e.g. /product but must distribute it in /system/product. Use argparse to cope with increased argument count. Test: Device without physical /product partition m out/target/product/<device>/shareduid_violation_modules.json -> Observe addition of violating apks from product partition in shareduid_violation_modules.json Signed-off-by: Felix <google@ix5.org> Change-Id: I2d7826b41fb5b924f15ae21a73178fa4eec6a879
This commit is contained in:
parent
4f353b78a7
commit
3769a205b6
|
@ -28,5 +28,13 @@ $(shareduid_violation_modules_filename): $(INSTALLED_SYSTEMIMAGE_TARGET) \
|
||||||
|
|
||||||
$(shareduid_violation_modules_filename): $(find_shareduid_script)
|
$(shareduid_violation_modules_filename): $(find_shareduid_script)
|
||||||
$(shareduid_violation_modules_filename): $(AAPT2)
|
$(shareduid_violation_modules_filename): $(AAPT2)
|
||||||
$(find_shareduid_script) $(PRODUCT_OUT) $(AAPT2) > $@
|
$(find_shareduid_script) \
|
||||||
|
--product_out $(PRODUCT_OUT) \
|
||||||
|
--aapt $(AAPT2) \
|
||||||
|
--copy_out_system $(TARGET_COPY_OUT_SYSTEM) \
|
||||||
|
--copy_out_vendor $(TARGET_COPY_OUT_VENDOR) \
|
||||||
|
--copy_out_product $(TARGET_COPY_OUT_PRODUCT) \
|
||||||
|
--copy_out_system_ext $(TARGET_COPY_OUT_SYSTEM_EXT) \
|
||||||
|
> $@
|
||||||
|
|
||||||
$(call dist-for-goals,droidcore,$(shareduid_violation_modules_filename))
|
$(call dist-for-goals,droidcore,$(shareduid_violation_modules_filename))
|
||||||
|
|
|
@ -14,19 +14,31 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from glob import glob
|
|
||||||
from collections import defaultdict
|
|
||||||
import sys
|
import sys
|
||||||
import json
|
|
||||||
|
|
||||||
if len(sys.argv) < 3:
|
from collections import defaultdict
|
||||||
product_out = os.environ["PRODUCT_OUT"]
|
from glob import glob
|
||||||
aapt = "aapt2"
|
|
||||||
else:
|
def parse_args():
|
||||||
product_out = sys.argv[1]
|
"""Parse commandline arguments."""
|
||||||
aapt = sys.argv[2]
|
parser = argparse.ArgumentParser(description='Find sharedUserId violators')
|
||||||
|
parser.add_argument('--product_out', help='PRODUCT_OUT directory',
|
||||||
|
default=os.environ.get("PRODUCT_OUT"))
|
||||||
|
parser.add_argument('--aapt', help='Path to aapt or aapt2',
|
||||||
|
default="aapt2")
|
||||||
|
parser.add_argument('--copy_out_system', help='TARGET_COPY_OUT_SYSTEM',
|
||||||
|
default="system")
|
||||||
|
parser.add_argument('--copy_out_vendor', help='TARGET_COPY_OUT_VENDOR',
|
||||||
|
default="vendor")
|
||||||
|
parser.add_argument('--copy_out_product', help='TARGET_COPY_OUT_PRODUCT',
|
||||||
|
default="product")
|
||||||
|
parser.add_argument('--copy_out_system_ext', help='TARGET_COPY_OUT_SYSTEM_EXT',
|
||||||
|
default="system_ext")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
def execute(cmd):
|
def execute(cmd):
|
||||||
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
@ -45,7 +57,6 @@ def extract_shared_uid(file):
|
||||||
else:
|
else:
|
||||||
print(error_msg, file=sys.stderr)
|
print(error_msg, file=sys.stderr)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
return None
|
|
||||||
|
|
||||||
for l in manifest.split('\n'):
|
for l in manifest.split('\n'):
|
||||||
if "sharedUserId" in l:
|
if "sharedUserId" in l:
|
||||||
|
@ -53,18 +64,28 @@ def extract_shared_uid(file):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
partitions = ["system", "vendor", "product"]
|
args = parse_args()
|
||||||
|
|
||||||
|
product_out = args.product_out
|
||||||
|
aapt = args.aapt
|
||||||
|
|
||||||
|
partitions = (
|
||||||
|
("system", args.copy_out_system),
|
||||||
|
("vendor", args.copy_out_vendor),
|
||||||
|
("product", args.copy_out_product),
|
||||||
|
("system_ext", args.copy_out_system_ext),
|
||||||
|
)
|
||||||
|
|
||||||
shareduid_app_dict = defaultdict(list)
|
shareduid_app_dict = defaultdict(list)
|
||||||
|
|
||||||
for p in partitions:
|
for part, location in partitions:
|
||||||
for f in glob(os.path.join(product_out, p, "*", "*", "*.apk")):
|
for f in glob(os.path.join(product_out, location, "*", "*", "*.apk")):
|
||||||
apk_file = os.path.basename(f)
|
apk_file = os.path.basename(f)
|
||||||
shared_uid = extract_shared_uid(f)
|
shared_uid = extract_shared_uid(f)
|
||||||
|
|
||||||
if shared_uid is None:
|
if shared_uid is None:
|
||||||
continue
|
continue
|
||||||
shareduid_app_dict[shared_uid].append((p, apk_file))
|
shareduid_app_dict[shared_uid].append((part, apk_file))
|
||||||
|
|
||||||
|
|
||||||
output = defaultdict(lambda: defaultdict(list))
|
output = defaultdict(lambda: defaultdict(list))
|
||||||
|
|
Loading…
Reference in New Issue