nolirium / aroc

Android root on Chrome OS
GNU General Public License v3.0
129 stars 51 forks source link

grant the Su privilege after root,but chinese font display messed up #1

Closed waldoxhm closed 5 years ago

waldoxhm commented 6 years ago

Hi~ greetings from Chinese chromebook user,I follow the readme file to finish root, the root and supersu works fine, but chinese font missing, and I tried to modify /system/etc/font.xml and want to put fonts into /system/font. all failed,these make no sense.finally trying to use unroot.sh to restore ,I even delete the whole android system and reinstall it. still a cross in a square except english. I think it's due to the policy30 and symbolic links.and while running unroot.sh I got traceback" sed: no such file or dictory" 请中文用户在备份前不要轻易尝试,android会丢失中文字体,貌似与软链接和selinux有关

model:Hana(lenovo chromebook yoga n23/flex11) chromeos version 63 beta channel

nolirium commented 6 years ago

Hello,

Thanks for the report, and I apologise for the delayed response.

I just installed some apps with Chinese fonts to check it out, and can see exactly what you mean.

Unfortunately this is due to a recent implementation of font sharing between Chrome OS and the Android subsystem (via a shared mount). This, for some reason, seems to break supersu when enabled. I noticed this a while ago, thus the script makes the following change in CrOS:

In /etc/init/arc-setup-env:

export SHARE_FONTS=1

is changed to

export SHARE_FONTS=0

The above change fixes supersu, but, as per your report, stops certain fonts being displayed correctly in Android.

Now that I am aware that this issue is impacting people, I will try to further investigate a possible fix.

To be honest, I think the current shared fonts implementation seems like a temporary workaround on the part of the CrOS developers. I mean, who wants the output of the "mount" command polluted by hundreds of lines of fonts names! Hopefully a more elegant implementation is in the works.

It's very inconvenient, so not really a workaround, but it is possible to switch shared fonts back on (which will break root) with something like the following

sed -i 's/export SHARE_FONTS=0/export SHARE_FONTS=1/g' /etc/init/arc-setup-env

After a reboot, shared fonts should work (but supersu will not work). Then, to reverse the process,

sed -i 's/export SHARE_FONTS=1/export SHARE_FONTS=0/g' /etc/init/arc-setup-env

In any case, I apologise for the inconvenience, and please be assured that I hope to find a proper fix for this issue soon.

nolirium commented 6 years ago

Hello,

Apologies for the delay in further response to this issue. I have found a workaround for this issue. (Going forward, it might be worth adding the missing fonts into the rooted container, but we will need to see how much space they all take up).

After rooting, if we do ls -alh /opt/google/containers/android/rootfs/root/system/fonts/

we can see the names of the missing fonts flashing in red (broken symlinks).

In order to get Chinese fonts showing up in the (few) Android apps which I tested, I copied the following font: NotoSansCJK-Regular.ttc from the ChromeOS side to the location which Android expected. It is, of course, possible, that you may need other fonts, in which case you can simply do the same with these.

The workaround, therefore, is to copy the required fonts in the CrOS shell from CrOS's /usr/share/fonts/ to Android's /system/fonts/chromeos/.

This was what I did to get the NotoSansCJK font working in Android:

In Chrome OS, go into a root shell (Ctrl+Alt+T, then sudo su);

In the CrOS root shell:


mount /usr/local/Android_Images/system.raw.expanded.img  /usr/local/Android_Images/Mounted/
mkdir -p /usr/local/Android_Images/Mounted/system/fonts/chromeos/notocjk/       
cp /usr/share/fonts/notocjk/NotoSansCJK-Regular.ttc /usr/local/Android_Images/Mounted/system/fonts/chromeos/notocjk/

(Rather than mounting, I expect you could copy straight into /opt/google/containers/android/rootfs/root/system/fonts/chromeos/ but I prefer to mount it separately)

After a reboot, in Android apps I was now able to see the Chinese font instead of the cross and square.

NB As I mentioned, I only tested a couple of apps. It's possible that you, or other people, may require other fonts in addition to NotoSansCJK-Regular.ttc. Like I say, of so, you should just be able to copy the required fonts across to Android's /system/fonts/chromeos/* (subject to available space).

Apologies again for the delayed response. I had hoped to be able to recreate something similar to the mounting method which CrOS uses by default in order to allow support for all these fonts, but so far I haven't been able to figure that one out satisfactorily. It seems like this mounting may be performed by one of the mysterious closed-source parts of the OS.

In any case, hope this helps. If not, or if you have further comment, please feel free to respond.

Also, if this does solve the issue for you, it would be good if you could let me know. If it's just NotoSansCJK-Regular.ttc that is required to support the necessary characters, we could probably add this to the script as it's only 18MB or so. Adding all of the missing fonts for all languages might be an issue though, as space is at a bit of a premium (on some devices).

waldoxhm commented 6 years ago

Thank you for the hardwork. I'll give a try sometime

waldoxhm commented 6 years ago
mount /usr/local/Android_Images/system.raw.expanded.img  /usr/local/Android_Images/Mounted/
mkdir -p /usr/local/Android_Images/Mounted/system/fonts/chromeos/notocjk/       
cp /usr/share/fonts/notocjk/NotoSansCJK-Regular.ttc /usr/local/Android_Images/Mounted/system/fonts/chromeos/notocjk/

(Rather than mounting, I expect you could copy straight into /opt/google/containers/android/rootfs/root/system/fonts/chromeos/ but I prefer to mount it separately)

these shell command doesn't work, I even download another fonts pack to replace them,all failed .English fonts do changed,but chinese didn't show up, still don't know why. And still unable to unroot just like last time,I recover the chrome os....wanna cry...LOL

nolirium commented 6 years ago

Sorry to hear that you've still been having trouble with this. Good news though, the implementation of Android font sharing has been changed in recent Chrome OS versions, and this issue with non-English font sets should no longer be present in Chrome OS version 66 and above.

Regarding unrooting, I'll have a look at the Unroot script as it may be out of date but in any case, the rooting script makes a back up of the original (unrooted) Android system image, and normally you should be able to restore this backup with a simple mv command, rather than having to do a full recovery of Chrome OS.

The command to restore the original Android system is the following:

sudo mv /opt/google/containers/android/system.raw.img.bk /opt/google/containers/android/system.raw.img

Edit: I'm closing this issue, since it's been a while now, and the problem should no longer occur on recent CrOS versions. Feel free to re-open if necessary.