FORUMS
Remove All Ads from XDA

[App] Patched Gmail to allow permission for third party notification widgets

1,705 posts
Thanks Meter: 2,394
 
By Tsjoklat, Senior Member on 3rd August 2011, 01:25 AM
Post Reply Email Thread
This is a modified version of Gmail that fixes the database permissions of Gmail so third party notification widgets (such as Missed It!, Go Notification, and Pure Messenger Widget) can determine which emails are read and which emails are unread for a true unread email count.

Code:
diff -ru Gmail.org/AndroidManifest.xml Gmail/AndroidManifest.xml
--- Gmail.org/AndroidManifest.xml	2011-08-02 22:49:48.356157842 +0200
+++ Gmail/AndroidManifest.xml	2011-08-02 22:52:05.603773155 +0200
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest android:versionCode="169" android:versionName="2.3.5" package="com.google.android.gm"
   xmlns:android="http://schemas.android.com/apk/res/android">
-    <permission android:label="@string/read_perm_label" android:name="com.google.android.gm.permission.READ_GMAIL" android:protectionLevel="signature" android:permissionGroup="android.permission-group.MESSAGES" android:description="@string/read_perm_desc" />
-    <permission android:label="@string/write_perm_label" android:name="com.google.android.gm.permission.WRITE_GMAIL" android:protectionLevel="signature" android:permissionGroup="android.permission-group.MESSAGES" android:description="@string/write_perm_desc" />
-    <permission android:label="@string/auto_send_perm_label" android:name="com.google.android.gm.permission.AUTO_SEND" android:protectionLevel="signature" android:permissionGroup="android.permission-group.MESSAGES" android:description="@string/auto_send_perm_desc" />
+    <permission android:label="@string/read_perm_label" android:name="com.google.android.gm.permission.READ_GMAIL" android:protectionLevel="normal" android:permissionGroup="android.permission-group.MESSAGES" android:description="@string/read_perm_desc" />
+    <permission android:label="@string/write_perm_label" android:name="com.google.android.gm.permission.WRITE_GMAIL" android:protectionLevel="normal" android:permissionGroup="android.permission-group.MESSAGES" android:description="@string/write_perm_desc" />
+    <permission android:label="@string/auto_send_perm_label" android:name="com.google.android.gm.permission.AUTO_SEND" android:protectionLevel="normal" android:permissionGroup="android.permission-group.MESSAGES" android:description="@string/auto_send_perm_desc" />
     <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" android:maxSdkVersion="10" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />
Requirements:

a) Your device does not come preinstalled with gmail so the original version can be completely uninstalled first before installing the modified version. After uninstalling original version of Gmail, install modified Gmail.apk as normal by running it.

OR

b) If you have root and your device has Gmail preinstalled in /system/app/Gmail.apk, then you have two choices. Either remove /system/app/Gmail.apk and install the modified version of Gmail normally by running the apk (to /data/app/Gmail.apk) OR replace /system/app/Gmail.apk with the modified version of Gmail. It is probably easier to remove Gmail.apk from the system partition and install it as a normal user application in /data/app/. However you want to do it..Gmail will install as a system or data application. To save space, I would not have it installed in both places.

Note: To simplify the installation of Gmail to the system partition for S-ON devices, I have added Gmail in a recovery flashable zip file format. This method requires busybox to be installed on your device. Make sure you uninstall any Gmail updates first, if possible. This method is only recommended if you have Gmail preinstalled to /system/app/Gmail.apk and you want to replace it with the modified version.


Note: After initially replacing or reinstalling Gmail with the modfied version, the notification widget (ie; Go Notification, Missed It!, or Pure Messenger Widget) needs to be reinstalled to regain premissions.

Note: Gmail 2.x is for Gingerbread. Gmail 3.x is for Honeycomb. Gmail 4.x is for ICS (but version 4.0.1 and 4.0.2 are reported working in Honeycomb too). At the time of this writing, ICS and Honeycomb support is limited. AFAIK, Pure Messenger Widget is the only third party notification widget that supports the ICS/Honeycomb Gmail protocol. Hopefully, more third party notification widgets will add support for ICS/Honeycomb in the future.

Updating from previous modified version of Gmail:

If you already have an older modified version of Gmail installed, the newer modified version of Gmail can be installed on top to perform the update. No need to remove the previously installed modified version of Gmail first.

Sources:

The latest versions of Gmail for ICS/Honeycomb are extracted from firmware from: http://www.sammobile.com/firmware/

Process:

1) Download latest Firmware from link above.

2) Extract files (this process requires linux)
a) Unzip or Unrar accordingly with samsung password (usually it is "samfirmware.com")
b) Extract again (tar -xf filename.tar.md5)
c) Extract again the largest file (a file.tar.md5 that is ~900MB) from the previous extraction. The largest file that is extracted contains the necessary system files. The system files can be found in two formats (system.rfs or factoryfs.img).

3) Process for reading system.rfs format (if system.rfs does not exist, skip to step #4)
a) Mount system.rfs using the following commands:
Code:
mkdir ~/tempdir
sudo losetup /dev/loop0 ./system.rfs
sudo mount -t vfat /dev/loop0 ~/tempdir
b) Copy necessary files to a writable location:
Code:
mkdir ~/workspace
cp -a ~/tempdir/system/framework ~/workspace/
cp -a ~/tempdir/system/apps ~/workspace/
c) Unmount and clean up
Code:
sudo umount /dev/loop0
sudo losetup -a
sudo losetup -d /dev/loop0
4) Process for reading factoryfs.img
a) Build ext4_utils from the following post: http://forum.xda-developers.com/show....php?t=1081239
b) Convert factoryfs.img to readable format with simg2img utility found in ext4_utils
Code:
simg2img factoryfs.img output.img
c) Mount output.img
Code:
mkdir ~/tempdir; sudo mount -o loop output.img ~/tempdir
d) Copy necessary files to a writable location:
Code:
mkdir ~/workspace
cp -a ~/tempdir/system/framework ~/workspace/
cp -a ~/tempdir/system/apps ~/workspace/
e) Unmount and clean up
Code:
sudo umount /dev/loop0
5) Creating classes.dex from Gmail.odex
a) Copy Gmail.odex into new framework directory from firmware image
Code:
cp ~/workspace/app/Gmail.odex ~/workspace/framework/
cd ~/workspace/framework/
b) Decompile odex file (api-level must be set accordingly) http://code.google.com/p/smali/
Code:
baksmali --api-levl 14 -x Gmail.odex
c) Compile output into classes.dex (api-level must be set accordingly)
Code:
smali --api-level 14 -o classes.dex out
6) Insert classes.dex into Gmail.apk
Code:
cp ~/workspace/app/Gmail.apk ~/workspace/framework/
mv Gmail.apk Gmail.zip
zip Gmail.zip -d META-INF/*
zip -o Gmail.zip classes.dex
mv Gmail.zip Gmail.apk
7) Decompile Gmail.apk with apktool (at the time of this writing it is apktool v1.4.3) http://code.google.com/p/android-apktool/
Code:
apktool d Gmail.apk
8) Edit AndroidManifest.xml (replacing "signature" with "normal"). See patch above for details.

9) Compile modified version of Gmail with apktool.
Code:
apktool b Gmail Gmail.mod.apk
Note: The current released version of apktool (1.4.3) will not be able to compile the resources for the new ICS api. Therefore, you will have to go into the res directory and delete all the resource directories that cause errors within apktool. After you delete those directories, you will see that apktool will also start showing errors in public.xml because resources are now missing. You will have to edit public.xml and delete the lines that show up as errors when compiling with apktool. Once you get the Gmail.mod.apk to build, extract the apk with unzip tool (unzip Gmail.mod.apk) and copy the extracted AndroidManifest.xml (in binary form) into an unaltered Gmail.apk that includes classes.dex. Rename original Gmail.apk to a zip file and insert the modified AndroidManifest.xml, then rename zip back to apk.

10) Sign Gmail with test keys:
Code:
java -jar /usr/local/bin/signapk.jar /usr/local/bin/testkey.x509.pem /usr/local/bin/testkey.pk8 Gmail.apk Gmail.mod-signed.apk
The Following 94 Users Say Thank You to Tsjoklat For This Useful Post: [ View ] Gift Tsjoklat Ad-Free
 
 
3rd August 2011, 01:14 PM |#2  
Senior Member
Thanks Meter: 47
 
More
Not working on an HD2 with Android 2.3.2.

Uninstalled all Gmail updates to go back to stock --> mod didn't install.
Updated to gmail 2.3.5 --> mod didn't install.
Deleted the updates and installed Gmail 2.3.4 --> mod didn't install
The Following 2 Users Say Thank You to Bunecarera For This Useful Post: [ View ] Gift Bunecarera Ad-Free
3rd August 2011, 01:37 PM |#3  
Fr4gg0r's Avatar
Inactive Recognized Developer
Flag Bremen
Thanks Meter: 688
 
Donate to Me
More
u sure this can work?
I thought about the same, but gmail surely requires permissions from talk.apk for google connection... which is again signature protected.
3rd August 2011, 04:49 PM |#4  
Junior Member
Thanks Meter: 0
 
More
I would assume you have to be rooted and use some kind of file manager to force this into place and even then, if as mentioned, you don't have any of the other files patched that are required... not gonna help so much.

Thanks for trying though.

I'm afraid gmail is sort of dead in the water until google decides to back down or provide some reasonable means of interaction for 3rd party applications.
3rd August 2011, 04:56 PM |#5  
Tsjoklat's Avatar
OP Senior Member
Thanks Meter: 2,394
 
More
This will only work if:

a) your phone does not come preinstalled with gmail so that it can be removed first before installing the modified version.

b) if you have root and can rename this file to Gmail.apk and copy it to system/app/ (replacing the original).

This fixes the database permissions of Gmail so third party applications can get the email count (such as Missed It! and Go Notification.

Note: After replacing or reinstalling Gmail, the notification widget (ie; Go Notification or Missed It!) needs to be reinstalled to regain premissions.
3rd August 2011, 06:10 PM |#6  
Tsjoklat's Avatar
OP Senior Member
Thanks Meter: 2,394
 
More
Quote:
Originally Posted by Fr4gg0r

u sure this can work?
I thought about the same, but gmail surely requires permissions from talk.apk for google connection... which is again signature protected.

This is unrelated to Talk.apk.
4th August 2011, 04:13 PM |#7  
Senior Member
Thanks Meter: 47
 
More
Alright, got it to work.

Updated to 2.3.5 from market from 2.3.4.
FC with "SMS unread count" and "Email Notifier"
Uninstalled these 2 apps.
Deleted gmail.apk from systems/apps (made back up first) with Root Explorer
Renamed modded version from Tsjoklat to gmail.apk and copied to system/apps with Root Explorer and set permissions to rw-rwe-re
Rebooted.
Installed Sms Unread Count and Email Notifier again and it's working. No FC's yet.
The Following 4 Users Say Thank You to Bunecarera For This Useful Post: [ View ] Gift Bunecarera Ad-Free
1st September 2011, 07:54 PM |#8  
BOO5TED's Avatar
Senior Member
Flag ATL
Thanks Meter: 92
 
Donate to Me
More
Definitely will try this tonight.
1st September 2011, 10:18 PM |#9  
th3taman's Avatar
Senior Member
Indy
Thanks Meter: 189
 
More
This is awesome! Can use the latest Gmail and SMS Unread Count widgets, I can't believe more don't know about this or use it!
7th September 2011, 09:55 AM |#10  
bartito's Avatar
Inactive Recognized Developer
Thanks Meter: 1,612
 
Donate to Me
More
another workarround
in order to have widgets working with gmail 2.3.5 you only need to resign the gmail 2.3.5 and widgets.

actions:

- download original gmail 2.3.5 from the android market
- copy the apk to your pc
- resign with apkmanager (you don't need to make any change in manifest.xml)
- uninstall original gmail in your android
- install resigned gmail in your android

make the same actions with your widgets...

works fine with "sms unread notifications", "gmail notifier", etc.

note 1: note that this method prevents other applications to access to your messages
note 2: when the widgets or gmail are updated in market, you need to uninstall resigned app in order to update. next, make the same actions...
The Following User Says Thank You to bartito For This Useful Post: [ View ] Gift bartito Ad-Free
16th September 2011, 05:44 AM |#11  
Member
Thanks Meter: 5
 
More
Quote:
Originally Posted by Bunecarera

Alright, got it to work.

Updated to 2.3.5 from market from 2.3.4.
FC with "SMS unread count" and "Email Notifier"
Uninstalled these 2 apps.
Deleted gmail.apk from systems/apps (made back up first) with Root Explorer
Renamed modded version from Tsjoklat to gmail.apk and copied to system/apps with Root Explorer and set permissions to rw-rwe-re
Rebooted.
Installed Sms Unread Count and Email Notifier again and it's working. No FC's yet.

niiice...ive been trying to get this working since the gmail update
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes