0

I have a Samsung t355c. A China model of the normal tablet that doesn't have gapps and as far as I get it a locked bootloader. There is no custom recovery for it. Runs 5.0.1

I managed to root it using kingo and tried many ways of pushing google apps into it. Ended up bricking it for now... redownloading original rom.

The question is. After I fix and root him again Using adb with the root . How can I push gapps

  • One method can be: extract the GApps zip and separate the files meant to be copied into the system partition. Then copy each of them individually to their intended location. In order to know the location, locate some script having instructions for Recovery. You would get the idea. Reboot and see what happens. – Firelord Nov 20 '15 at 18:13
  • 1
    Don't forget to adjust permissions (also found in that script). Plus you will need to remount /system read-write before, and back to read-only after pushing the apps. – Izzy Nov 20 '15 at 18:55
  • used link2sd to convert them to system, after some errors, logged into google have gmail, but can't connect the playstore @Izzy what permissions do i need to change? – Iakovl Nov 20 '15 at 19:38
  • 1
    As @Firelord already pointed out, the .zip contains a script: META-INF/com/google/android/updater-script contains the steps a custom recovery would execute usually. Use that as a guide – though you will have to "convert" the commands. – Izzy Nov 20 '15 at 19:42
2

I have not really tried this, but a possible approach would be following the steps a custom recovery would perform when installing ("flashing") the .zip file – which can be found in META-INF/com/google/android/updater-script (after extracting the archive). For the Kitkat GApps archive, this looks like:

ui_print("Installing files...");
run_program("/sbin/busybox", "mount", "/system");
show_progress(1, 15);
delete("/system/app/Provision.apk","/system/app/QuickSearchBox.apk","/system/app/priv-app/SetupWizard.apk","/system/app/priv-app/Velvet.apk","/system/app/Vending.apk","/system/app
package_extract_dir("system", "/system");
set_perm(0, 0, 0755, "/system/addon.d/70-gapps.sh");
package_extract_dir("optional", "/tmp");
package_extract_file("install-optional.sh", "/tmp/install-optional.sh");
set_perm(0, 0, 0777, "/tmp/install-optional.sh");
run_program("/tmp/install-optional.sh", "");
show_progress(1, 15);
ui_print("Cleaning up and setting metadata...");
set_metadata_recursive("/system/addon.d", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/priv-app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/permissions", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/preferred-apps", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata("/system/etc/g.prop", "uid", 0, "gid", 0, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/framework", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/lib", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/usr/srec/en-US", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/vendor/pittpatt", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
run_program("/sbin/busybox", "umount", "/system");
ui_print("Installation complete!");

We of course can skip the comments/debug-output, and thus essentially end up with these steps. I assume you've unpacked the .zip file's contents somewhere on your device, and are sitting in a shell (terminal or adb shell) with root permissions (su) to start with:

  1. mount -o remount,rw /system (line 2)
  2. if the files listed in line 4 exist: rm -f <file> for each of them
  3. copy all contents of the .zip file's system/ directory to /system (line 5)
  4. chmod 0755 /system/addon.d/70-gapps.sh (line 6)
  5. ( apply the previous 2 steps on lines 7-9 )
  6. sh /tmp/install-optional.sh (line 10)

Now it gets a little more difficult (for beginners) interpreting the set_metadata_recursive commands. I'll explain this on the first one (line 13):

/system/addon.d must be owned by uid 0 and gid 0, file permissions should be 0755 (dmode is directory mode, fmode file mode), SELinux attributes are u:object_r:system_file:s0. You might have noticed I've skipped two columns: I have no idea what the "capabilities", 0x0 stands for, so I cannot explain it (if anyone does, please comment). So let's do that:

chown -R root:root /system/addon.d   # -R is recursive, root is user/group id 0
chmod -R 755 /system/addon.d         # as dmode and fmode are the same, we can do that
# at this place missing: SELinux properties. I've never dealt with those

If like in line 14 fmode and dmode are different, you'll have to take care for that as well. Apply dmode as above, and follow it by a find <dir> -type f -print0 | xargs chmod <mode>, replacing <dir> by the first argument of set_metadata_recursive, and <mode> by the corresponding fmode.

Finally, remount /system read-only again: mount -o remount,ro /system – or simply reboot (you'll have to anyway), which takes care for that as well.

I have skipped the SELinux stuff due to missing knowledge. It will most likely work without – but might be good to do for additional security :)

| improve this answer | |
  • Some GApps comes with gapps-remove.txt file as well. One can compare it with the files one have or is going to copy in /system. That can help them to know what they may be missing. – Firelord Nov 20 '15 at 21:07
0

SElinux labels you set with "chcon" command and you can the result verify by using "ls -laZ".

For: set_metadata_recursive("/system/addon.d", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");

it will be: chcon "u:object_r:system_file:s0" /system/addon.d

You can verify this by issuing: ls -laZ /system/addon.d

source for usage of "chcon": https://books.google.pl/books?id=AKbNBgAAQBAJ&pg=PA101&lpg=PA101&dq=%22u:object_r:system_file:s0%22&source=bl&ots=MbpesnKLkI&sig=ACfU3U2sJc-vYndDkUOk1Tru42hrcuPyUQ&hl=pl&sa=X&ved=2ahUKEwjqwqKiwZDnAhWiAxAIHZH8AGAQ6AEwAXoECAkQAQ#v=onepage&q=%22u%3Aobject_r%3Asystem_file%3As0%22&f=false

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.