[
  {
    "path": ".gitattributes",
    "content": "# Declare files that will always have LF line endings on checkout.\nMETA-INF/** text eol=lf\n*.prop text eol=lf\n*.sh text eol=lf\n*.md text eol=lf\n\n# Denote all files that are truly binary and should not be modified.\nsystem/** binary\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: [AndroPlus-org]\ncustom: ['https://paypal.me/androplus']\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: Create Archive\non:\n  push:\n    tags:\n      - 'v*'\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@master\n    - name: Archive Release\n      uses: thedoctor0/zip-release@master\n      with:\n        type: 'zip'\n        filename: 'magisk-module-hyperos-cn2global.zip'\n        exclusions: '*.git* /*node_modules/* .editorconfig'\n    - name: Archive Release without languages\n      uses: thedoctor0/zip-release@master\n      with:\n        type: 'zip'\n        filename: 'magisk-module-hyperos-cn2global-no-languages.zip'\n        exclusions: '*.git* /*node_modules/* .editorconfig treble-overlay-*.apk'\n    - name: Upload Release\n      uses: ncipollo/release-action@v1\n      with:\n        artifacts: \"magisk-module-hyperos-cn2global.zip,magisk-module-miui-cn2global-no-languages.zip\"\n        token: ${{ secrets.GITHUB_TOKEN }}\n"
  },
  {
    "path": ".gitignore",
    "content": "*.zip"
  },
  {
    "path": "META-INF/com/google/android/update-binary",
    "content": "#!/sbin/sh\n\n#################\n# Initialization\n#################\n\numask 022\n\n# echo before loading util_functions\nui_print() { echo \"$1\"; }\n\nrequire_new_magisk() {\n  ui_print \"*******************************\"\n  ui_print \" Please install Magisk v20.0+! \"\n  ui_print \"*******************************\"\n  exit 1\n}\n\n#########################\n# Load util_functions.sh\n#########################\n\nOUTFD=$2\nZIPFILE=$3\n\nmount /data 2>/dev/null\n\n[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk\n. /data/adb/magisk/util_functions.sh\n[ $MAGISK_VER_CODE -lt 20000 ] && require_new_magisk\n\nif [ $MAGISK_VER_CODE -ge 20400 ]; then\n  # New Magisk have complete installation logic within util_functions.sh\n  install_module\n  exit 0\nfi\n\n#################\n# Legacy Support\n#################\n\nTMPDIR=/dev/tmp\nPERSISTDIR=/sbin/.magisk/mirror/persist\n\nis_legacy_script() {\n  unzip -l \"$ZIPFILE\" install.sh | grep -q install.sh\n  return $?\n}\n\nprint_modname() {\n  local authlen len namelen pounds\n  namelen=`echo -n $MODNAME | wc -c`\n  authlen=$((`echo -n $MODAUTH | wc -c` + 3))\n  [ $namelen -gt $authlen ] && len=$namelen || len=$authlen\n  len=$((len + 2))\n  pounds=$(printf \"%${len}s\" | tr ' ' '*')\n  ui_print \"$pounds\"\n  ui_print \" $MODNAME \"\n  ui_print \" by $MODAUTH \"\n  ui_print \"$pounds\"\n  ui_print \"*******************\"\n  ui_print \" Powered by Magisk \"\n  ui_print \"*******************\"\n}\n\n# Override abort as old scripts have some issues\nabort() {\n  ui_print \"$1\"\n  $BOOTMODE || recovery_cleanup\n  [ -n $MODPATH ] && rm -rf $MODPATH\n  rm -rf $TMPDIR\n  exit 1\n}\n\nrm -rf $TMPDIR 2>/dev/null\nmkdir -p $TMPDIR\n\n# Preperation for flashable zips\nsetup_flashable\n\n# Mount partitions\nmount_partitions\n\n# Detect version and architecture\napi_level_arch_detect\n\n# Setup busybox and binaries\n$BOOTMODE && boot_actions || recovery_actions\n\n##############\n# Preparation\n##############\n\n# Extract prop file\nunzip -o \"$ZIPFILE\" module.prop -d $TMPDIR >&2\n[ ! -f $TMPDIR/module.prop ] && abort \"! Unable to extract zip file!\"\n\n$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules\nMODULEROOT=$NVBASE/$MODDIRNAME\nMODID=`grep_prop id $TMPDIR/module.prop`\nMODNAME=`grep_prop name $TMPDIR/module.prop`\nMODAUTH=`grep_prop author $TMPDIR/module.prop`\nMODPATH=$MODULEROOT/$MODID\n\n# Create mod paths\nrm -rf $MODPATH 2>/dev/null\nmkdir -p $MODPATH\n\n##########\n# Install\n##########\n\nif is_legacy_script; then\n  unzip -oj \"$ZIPFILE\" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2\n\n  # Load install script\n  . $TMPDIR/install.sh\n\n  # Callbacks\n  print_modname\n  on_install\n\n  # Custom uninstaller\n  [ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh\n\n  # Skip mount\n  $SKIPMOUNT && touch $MODPATH/skip_mount\n\n  # prop file\n  $PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop\n\n  # Module info\n  cp -af $TMPDIR/module.prop $MODPATH/module.prop\n\n  # post-fs-data scripts\n  $POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh\n\n  # service scripts\n  $LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh\n\n  ui_print \"- Setting permissions\"\n  set_permissions\nelse\n  print_modname\n\n  unzip -o \"$ZIPFILE\" customize.sh -d $MODPATH >&2\n\n  if ! grep -q '^SKIPUNZIP=1$' $MODPATH/customize.sh 2>/dev/null; then\n    ui_print \"- Extracting module files\"\n    unzip -o \"$ZIPFILE\" -x 'META-INF/*' -d $MODPATH >&2\n\n    # Default permissions\n    set_perm_recursive $MODPATH 0 0 0755 0644\n  fi\n\n  # Load customization script\n  [ -f $MODPATH/customize.sh ] && . $MODPATH/customize.sh\nfi\n\n# Handle replace folders\nfor TARGET in $REPLACE; do\n  ui_print \"- Replace target: $TARGET\"\n  mktouch $MODPATH$TARGET/.replace\ndone\n\nif $BOOTMODE; then\n  # Update info for Magisk Manager\n  mktouch $NVBASE/modules/$MODID/update\n  cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop\nfi\n\n# Copy over custom sepolicy rules\nif [ -f $MODPATH/sepolicy.rule -a -e $PERSISTDIR ]; then\n  ui_print \"- Installing custom sepolicy patch\"\n  # Remove old recovery logs (which may be filling partition) to make room\n  rm -f $PERSISTDIR/cache/recovery/*\n  PERSISTMOD=$PERSISTDIR/magisk/$MODID\n  mkdir -p $PERSISTMOD\n  cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule || abort \"! Insufficient partition size\"\nfi\n\n# Remove stuffs that don't belong to modules\nrm -rf \\\n$MODPATH/system/placeholder $MODPATH/customize.sh \\\n$MODPATH/README.md $MODPATH/.git* 2>/dev/null\n\n#############\n# Finalizing\n#############\n\ncd /\n$BOOTMODE || recovery_cleanup\nrm -rf $TMPDIR\n\nui_print \"- Done\"\nexit 0\n"
  },
  {
    "path": "META-INF/com/google/android/updater-script",
    "content": "#MAGISK\n"
  },
  {
    "path": "README.md",
    "content": "## Translation Patch for Xiaomi HyperOS China\n\nThis is a Magisk module to add translation to the Chinese version of Xiaomi HyperOS.  \nThis module also enables Google Location history and Nearby share.\n\nDownload magisk-module-hyperos-cn2global.zip, install this module from the Modules tab of the Magisk app and restart, then you will be able to select your language in the language settings.\n\n## Prohibitions\n\nFor reasons of support, etc., commercial use of this module is prohibited. (except in cases of special permission).  \n(e.g.: Selling or exhibiting device contains this module, selling articles on installation procedures for a fee, etc.)\n\nIn case of commercial use, 50% of the profit will be collected.\n\n## 日本語説明\n中国版 Xiaomi HyperOS に日本語翻訳を追加する Magisk モジュールです。    \nGoogle ロケーション履歴やニアバイシェアも有効化されます。\n\nmagisk-module-hyperos-cn2global.zip をダウンロードして Magisk アプリのモジュールタブからこのモジュールをインストール・再起動することで、言語設定で日本語が選べるようになります。\n\n## 禁止事項\n\nサポート等の都合上、このモジュールの商用利用を禁じます。(特別に許可された場合を除く)  \n例: このモジュールで日本語化した状態の端末を販売・出品する、導入手順の記事を全文無料公開せずに有料販売するなど\n\n商用利用された場合、利益の50%を徴収させていただきます。"
  },
  {
    "path": "customize.sh",
    "content": "REPLACE=\"\n\"\n\n# Taken from unlock-cn-gms\n# Credit: Howard20181, yujincheng08 https://github.com/yujincheng08/unlock-cn-gms\nPERMISSIONS_PATH=/etc/permissions\nSYSTEM_PATH=/system\nSYSTEM_EXT_PATH=$SYSTEM_PATH/system_ext\nPRODUCT_PATH=$SYSTEM_PATH/product\nVENDOR_PATH=$SYSTEM_PATH/vendor\nOPLUS_BIGBALL_PATH=/my_bigball\nOPLUS_BIGBALL_VENDOR_PATH=/mnt/vendor$OPLUS_BIGBALL_PATH\nROOT_LIST=\"\"$SYSTEM_PATH$PERMISSIONS_PATH\" \"$PRODUCT_PATH$PERMISSIONS_PATH\" \"$VENDOR_PATH$PERMISSIONS_PATH\" \"$SYSTEM_EXT_PATH$PERMISSIONS_PATH\" \"$OPLUS_BIGBALL_PATH$PERMISSIONS_PATH\" \"$OPLUS_BIGBALL_VENDOR_PATH$PERMISSIONS_PATH\"\"\nFILE_LIST=\"services.cn.google.xml cn.google.services.xml oplus_google_cn_gms_features.xml\"\nfor ROOT in $ROOT_LIST; do\n    for FILE in $FILE_LIST; do\n        if [ -f \"$ROOT/$FILE\" ]; then\n            PERMISSION_PATH=\"$MODPATH$ROOT\"\n            FILE_NAME=$FILE\n            ui_print \"- PATH $ROOT/$FILE_NAME\"\n            mkdir -p \"$PERMISSION_PATH\"\n            cat >\"$PERMISSION_PATH/$FILE_NAME\" <<EOF\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- This is the standard set of features for devices that support the CN GMSCore. -->\nEOF\n            [ \"$ROOT\" = \"$OPLUS_BIGBALL_PATH$PERMISSIONS_PATH\" ] || [ \"$ROOT\" = \"$OPLUS_BIGBALL_VENDOR_PATH$PERMISSIONS_PATH\" ]  && {\n                if [ ! -f \"$MODPATH/post-fs-data.sh\" ]; then\n                    cat >\"$MODPATH/post-fs-data.sh\" <<EOF\n#!/system/bin/sh\nMODDIR=\\${0%/*}\nEOF\n                fi\n                echo \"mount -o ro,bind \\$MODDIR$ROOT/$FILE_NAME $ROOT/$FILE_NAME\" >> \"$MODPATH/post-fs-data.sh\"\n            }\n        fi\n    done\ndone\n\n# Set permissions for Google Dialer if it's default app\nDEF_DIALER=`cmd package resolve-activity --brief -a android.intent.action.DIAL | grep com.google.android.dialer`\nif [ -n \"$DEF_DIALER\" ]; then\n    cp -a ${MODPATH}/cn2g-optional/GmsConfigOverlayComms.apk ${MODPATH}/system/product/overlay\n    ui_print \"\"\n    ui_print \"******⚠注意⚠******\"\n    ui_print \"Google 電話アプリを必ずデフォルトの電話アプリに\"\n    ui_print \"設定して、権限や通知、自動起動を設定してください。\"\n    ui_print \"設定していないと受話できなくなります。\"\n    ui_print \"******⚠注意⚠******\"\n    ui_print \"\"\n    ui_print \"\"\n    ui_print \"******⚠ WARNING ⚠******\"\n    ui_print \"Please set Google Phone app as default-\"\n    ui_print \"phone app and setup permissions / autostart.\"\n    ui_print \"If you don't, you can't receive a call.\"\n    ui_print \"******⚠ WARNING ⚠******\"\n    ui_print \"\"\nfi\n\nrm -rf ${MODPATH}/cn2g-optional"
  },
  {
    "path": "module.prop",
    "content": "id=xiaomi-miui-conv\nname=Patch for Xiaomi HyperOS China\nversion=v17\nversionCode=17\nauthor=AndroPlus\ndescription=Xiaomi HyperOS China to Global\nupdateJson=https://raw.githubusercontent.com/AndroPlus-org/magisk-module-miui-cn2global/master/update.json"
  },
  {
    "path": "post-fs-data.sh",
    "content": "#!/system/bin/sh\n# Do NOT assume where your module will be located.\n# ALWAYS use $MODDIR if you need to know where this script\n# and module is placed.\n# This will make sure your module will still work\n# if Magisk change its mount point in the future\nMODDIR=${0%/*}\n# This script will be executed in post-fs-data mode\n\n#resetprop ro.boot.hwc GLOBAL\n#resetprop ro.boot.hwcountry GLOBAL\n\nmaybe_set_prop() {\n    local prop=\"$1\"\n    local contains=\"$2\"\n    local value=\"$3\"\n\n    if [[ \"$(getprop \"$prop\")\" == *\"$contains\"* ]]; then\n        resetprop \"$prop\" \"$value\"\n    fi\n}\n\nmaybe_set_prop gsm.sim.operator.numeric \",\" \"44011,44011\"\nmaybe_set_prop gsm.sim.operator.iso-country \",\" \"jp,jp\"\n\n# Change to MIUI Global (but less features)\n# resetprop ro.product.mod_device \"$(getprop \"ro.product.mod_device\")_global\""
  },
  {
    "path": "system/product/etc/default-permissions/default-permissions-google.xml",
    "content": "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<exceptions>\n  <exception\n    package=\"com.google.android.apps.restore\"\n    sha256-cert-digest=\"56:BE:13:2B:78:06:56:FE:24:44:CD:34:32:6E:B5:D7:AA:C9:1D:20:96:AB:F0:FE:67:3A:99:27:06:22:EC:87\">\n    <!-- External storage -->\n    <permission name=\"android.permission.READ_EXTERNAL_STORAGE\" fixed=\"false\"/>\n    <permission name=\"android.permission.WRITE_EXTERNAL_STORAGE\" fixed=\"false\"/>\n    <!-- Contacts -->\n    <permission name=\"android.permission.READ_CONTACTS\" fixed=\"false\"/>\n    <permission name=\"android.permission.WRITE_CONTACTS\" fixed=\"false\"/>\n    <!-- For D2D Restore -->\n    <permission name=\"android.permission.READ_CALL_LOG\" fixed=\"false\"/>\n    <permission name=\"android.permission.WRITE_CALL_LOG\" fixed=\"false\"/>\n    <permission name=\"android.permission.NEARBY_WIFI_DEVICES\" fixed=\"false\"/>\n    <permission name=\"android.permission.POST_NOTIFICATIONS\" fixed=\"false\"/>\n  </exception>\n\n  <exception\n    package=\"com.google.android.apps.assistant\"\n    sha256-cert-digest=\"43:0B:20:EB:61:96:7E:9C:5B:BE:02:59:9B:07:35:16:80:7D:AE:72:D7:86:FE:92:7F:48:96:B7:C7:F2:96:1F\">\n    <!-- Record audio -->\n    <permission name=\"android.permission.RECORD_AUDIO\" fixed=\"false\"/>\n  </exception>\n\n  <exception\n    package=\"com.google.android.apps.actionsservice\"\n    sha256-cert-digest=\"43:0B:20:EB:61:96:7E:9C:5B:BE:02:59:9B:07:35:16:80:7D:AE:72:D7:86:FE:92:7F:48:96:B7:C7:F2:96:1F\">\n    <!-- Record audio -->\n    <permission name=\"android.permission.RECORD_AUDIO\" fixed=\"false\"/>\n  </exception>\n\n  <exception\n    package=\"com.google.android.marvin.talkback\"\n    sha256-cert-digest=\"7B:5A:D5:51:80:A4:8A:1F:30:F3:53:77:C0:F9:E5:F9:11:BF:94:2F:B4:CF:83:EB:A2:55:A0:EB:F5:80:BE:EF\">\n    <!-- Read phone status -->\n    <permission name=\"android.permission.READ_PHONE_STATE\" fixed=\"false\"/>\n    <!-- Bluetooth permissions -->\n    <permission name=\"android.permission.BLUETOOTH_CONNECT\" fixed=\"false\"/>\n    <permission name=\"android.permission.BLUETOOTH_SCAN\" fixed=\"false\"/>\n    <permission name=\"android.permission.BLUETOOTH_ADVERTISE\" fixed=\"false\"/>\n  </exception>\n\n  <exception\n    package=\"com.google.android.apps.photos\"\n    sha256-cert-digest=\"3D:7A:12:23:01:9A:A3:9D:9E:A0:E3:43:6A:B7:C0:89:6B:FB:4F:B6:79:F4:DE:5F:E7:C2:3F:32:6C:8F:99:4A\">\n    <!-- Grant media access to Photos APK -->\n    <permission name=\"android.permission.ACCESS_MEDIA_LOCATION\" fixed=\"false\"/>\n    <permission name=\"android.permission.READ_MEDIA_IMAGES\" fixed=\"false\"/>\n    <permission name=\"android.permission.READ_MEDIA_VIDEO\" fixed=\"false\"/>\n  </exception>\n\n</exceptions>\n"
  },
  {
    "path": "system/product/etc/sysconfig/d2d_cable_migration_feature.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<config>\n    <feature name=\"com.google.android.feature.D2D_CABLE_MIGRATION_FEATURE\" />\n</config>\n"
  },
  {
    "path": "system/product/etc/sysconfig/google-staged-installer-whitelist.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<!--\n This XML file declares installer eligible for committing stage install.\n-->\n<config>\n  <whitelisted-staged-installer package=\"com.android.vending\" isModulesInstaller=\"true\" />\n</config>\n"
  },
  {
    "path": "system/product/etc/sysconfig/wellbeing.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<config>\n    <feature name=\"com.google.android.feature.WELLBEING\" />\n</config>\n"
  },
  {
    "path": "system.prop",
    "content": "ro.product.locale=en-US\n\n# Change to MIUI Global (but less features)\n# ro.miui.region=JP\n# ro.rom.zone=1\n"
  },
  {
    "path": "update.json",
    "content": "{\n\t\"version\": \"v17\",\n\t\"versionCode\": 17,\n\t\"zipUrl\": \"https://github.com/AndroPlus-org/magisk-module-miui-cn2global/releases/latest/download/magisk-module-miui-cn2global.zip\",\n\t\"changelog\": \"https://raw.githubusercontent.com/AndroPlus-org/magisk-module-miui-cn2global/master/README.md\"\n}"
  }
]