[Q] Filter Contacts by Group with ContactsContract - Android Q&A, Help & Troubleshooting

Hello!
I'm developing a big application and a part of it is about contacts. I want to, first, get all the groups of contacts. And when the users selects one, show all the contacts of the group.
I've seen other applications and widgets (like LauncherPro widget or HTC Sense Widget) than can do it, but when I try, I don't get same results.
My code is:
1.- To get an example group (this is just for testing, in real application user selects):
Code:
long idGroup = 0;
String[] GROUP_PROJECTION = new String[] {
ContactsContract.Groups._ID, ContactsContract.Groups.TITLE };
Cursor c = mcp.getContext().getContentResolver().query(ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null, null, ContactsContract.Groups.TITLE + " ASC");
while(c.moveToNext())
{
if (c.getString(1).contains("Family")){
idGroup = c.getLong(0);
}
}
c.close();
2.- To filter Users by group??
Thank you!

2.- To filter Users by group??
Same question... Cannot find the answer... Anybody knows ?

well maybe i should not revive this thread, but i had a lot of issues finding this,, my code working and you can filter and avoid repeated groups and only with phone numbers
Code:
String[] GROUP_PROJECTION = new String[] {
ContactsContract.Groups._ID, ContactsContract.Groups.TITLE,ContactsContract.Groups.SUMMARY_COUNT ,ContactsContract.Groups.SUMMARY_WITH_PHONES };
Cursor c = context.getApplicationContext().getContentResolver().query(
ContactsContract.Groups.CONTENT_SUMMARY_URI,
GROUP_PROJECTION,
ContactsContract.Groups.SUMMARY_WITH_PHONES +"> 0"
, null, ContactsContract.Groups.TITLE + " ASC");

Related

[R&D] Upload files with DropBox

Hi, this is my code, i cant get upload a simple file:
Signgin in to DropBox:
.....private AccessTokenPair tokensDB;
.....private DropboxAPI<AndroidAuthSession> mDBApi;
.....final static private AccessType ACCESS_TYPE = AccessType.DROPBOX;
.....AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
.....AndroidAuthSession sesDropBox = new AndroidAuthSession(appKeys, ACCESS_TYPE);
.....mDBApi = new DropboxAPI<AndroidAuthSession>(sesDropBox);
.....mDBApi.getSession().startAuthentication(this);
When activity resums this code is executed:
.....mDBApi.getSession().finishAuthentication();
.....tokensDB = mDBApi.getSession().getAccessTokenPair();
when the user clicks over a button in same activity next code is executed:
protected void subeArchivos() {
.....// Uploading content.
.....String fileContents = "Hello World, this is only an example!!";
.....ByteArrayInputStream inputStream = new ByteArrayInputStream(fileContents.getBytes());
.....try {
..........mDBApi.putFile("/testing.txt", inputStream, fileContents.length(), null, null);
..........//Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
.....} catch (DropboxUnlinkedException e) {
..........// User has unlinked, ask them to link again here.
..........Log.e("DbExampleLog", "User has unlinked.");
.....} catch (DropboxException e) {
..........toast = Toast.makeText(getApplicationContext(), "C U A: " + e.getMessage(), Toast.LENGTH_SHORT);
..........toast.show();
..........//Log.e("DbExampleLog", "Something went wrong while uploading.");
.....}
}
The code in red throws error. and after the conde in yellow is executed.
My mnifiest permissions are:
.....<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
.....<uses-permission android:name="android.permission.INTERNET"></uses-permission>
.....<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
P.D. All works, exept code in red!!
I hope you can help me!! thx!!
anyone??
I didn't understand anything exc. that you can't upload any file with Dropbox, but I had similar problem. Seems you shouldn't delete the Downloads app, else it bugs DB uploads.
Hope it helps.
thx man, every folder in his place, but maybe something in my code is wrong!!

[Q] GoogleMap resets and stops responding

Hi all..
I am not sure this is the right sub-forum to post in, but here goes.
I am working on an app that uses a GoogleMap and lots of overlays/markers. Controls and navigation is handled automatically (no direct user interaction with the map needed so far).
Things work the way I want right until the app pauses and goes into the background. When I resume the app the map has zoomed out to 0:0 and it doesn't react to animateMap or anything anymore. I can't seem to figure how I get it back to the state where it doesn't react to user interaction and actually updates with my markers and stuff..
Below are the three methods handling the map, and it doesn't seem to react on any of it after a resume. Any hints?
Code:
private void setupMap(){
getSupportFragmentManager().beginTransaction().replace(R.id.trackeractivity_map, new SupportMapFragment()).commit();
FragmentManager fragmentManager = getSupportFragmentManager();
SupportMapFragment supportMapFragment = (SupportMapFragment) fragmentManager.findFragmentById(R.id.trackeractivity_map);
mMap = supportMapFragment.getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.setMyLocationEnabled(true);
Log.d(TAG, "Max zoom level " + mMap.getMaxZoomLevel());
}
private void updateUserLocation(double lat, double lon){
Log.d(TAG, "updateUserLocation - " + lat + " : " + lon);
mLastLocationLat = lat;
mLastLocationLon = lon;
CameraPosition userPos = new CameraPosition(new LatLng(lat, lon), mMap.getMaxZoomLevel()-4, 0, 0);
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(userPos));
}
private void updateMapOverlay(double lat, double lon){
Log.d(TAG, "updateMapOverlay - " + lat + " : " + lon + " - Type " + mCurrentType);
MarkerOptions marker = new MarkerOptions();
marker.position(new LatLng(lat, lon));
marker.draggable(false);
marker.icon(BitmapDescriptorFactory.fromResource(getTypeDrawableID(mCurrentType)));
mMap.addMarker(marker);
}
Try to re flash Google apps package or restore any previous nandroid backup
FRIEND IF I HELPED YOU HIT THANKS
Androyash said:
Try to re flash Google apps package or restore any previous nandroid backup
FRIEND IF I HELPED YOU HIT THANKS
Click to expand...
Click to collapse
That, unfortunately, didn't help.. Still does the same thing.. Bugs the crap out of me..
Maybe it is just me, but how do i set UISettings on the map? There only seems to be a method to get them?
https://developers.google.com/maps/...erence/com/google/android/gms/maps/UiSettings

[Q] advances 1.1 send IMEI to server

Hi all,
I searched the forum but cannot find one thread about this topic.
has anyone noticed that the app AdvanceS 1.1 send the IMEI to a server called loc.lidroid.com ?
Can anyone explain why this should nessesary ???
Thx in advance
Dys
Dys66 said:
Hi all,
I searched the forum but cannot find one thread about this topic.
has anyone noticed that the app AdvanceS 1.1 (which is probably part of Omega-ROM) send the IMEI to a server called loc.lidroid.com ?
Can anyone explain why this should nessesary ???
Thx in advance
Dys
Click to expand...
Click to collapse
I would get rid of that app no one should have your IMEI number that is really bad for you
Sent from my Nexus 4 using Tapatalk 2
......and report it too Google while you are at it, if it came from the play store
slaphead20 said:
......and report it too Google while you are at it, if it came from the play store
Click to expand...
Click to collapse
I froze it for now with Titanium.
But AdvanceS seems to be part of lidroid Mod which is probably included with Omega and other ROMS and is NOT out of Google Play.
Seems to be a config-tool for SystemUI. I don't used it so far ...
Therefore I think it will reactivated when I flash a new version of the ROM.
Dys66 said:
I froze it for now with Titanium.
But AdvanceS seems to be part of lidroid Mod which is probably included with Omega and other ROMS and is NOT out of Google Play.
Seems to be a config-tool for SystemUI. I don't used it so far ...
Therefore I think it will reactivated when I flash a new version of the ROM.
Click to expand...
Click to collapse
I see what it is control toggles app for lidroid delete it no matter what should not be uploading your IMEI number dev or no dev
Sent from my Nexus 4 using Tapatalk 2
Hmmmm.......I think I will notify the mods about this and let them get to the bottom of it
Edit...done.
OP Was this mod something you got off XDA? If so could you point me to it. I know of the mod and I've used it in my own roms but like others have said, It shouldn't be uploading your IMEI number anywhere. If it is, you might have gotten a hacked version of the mod with maliciousness code. If the source is XDA please let me know ASAP so we can look into it. If it's not from XDA then there really isn't much we can do about it
graffixnyc said:
OP Was this mod something you got off XDA? If so could you point me to it. I know of the mod and I've used it in my own roms but like others have said, It shouldn't be uploading your IMEI number anywhere. If it is, you might have gotten a hacked version of the mod with maliciousness code. If the source is XDA please let me know ASAP so we can look into it. If it's not from XDA then there really isn't much we can do about it
Click to expand...
Click to collapse
Now That's what i call swift action :thumbup: he did say he mite of come woth omega rom so that could mean he did not install a apk
Sent from my Nexus 4 using Tapatalk 2
just looked at loc.lidroid.com - seems to list phone numbers, all seem to be in China though ...
mikep99 said:
just looked at loc.lidroid.com - seems to list phone numbers, all seem to be in China though ...
Click to expand...
Click to collapse
Hmm, it seems NOT inside my Omega Package.
But I never installed any apps from other locations than XDA or google play.
I will try to find the app in the files i got on my harddisk ...
The app is named "com.lidroid.settings" when I see it right in Titanium
It maintains a database "telocation.db" ... the content seems to be chinese :S
I exported the content for further investigation and will uninstall and delete that crap from my phone ...
Hope that droidwall has blocked the network access :S
Dys66 said:
Hmm, it seems NOT inside my Omega Package.
But I never installed any apps from other locations than XDA or google play.
I will try to find the app in the files i got on my harddisk ...
The app is named "com.lidroid.settings" when I see it right in Titanium
It maintains a database "telocation.db" ... the content seems to be chinese :S
I exported the content for further investigation and will uninstall and delete that crap from my phone ...
Hope that droidwall has blocked the network access :S
Click to expand...
Click to collapse
Info - im assuming omegarom uses 23 toggle mod from lidroid - that app is the options app, deleting it will disable 23 toggle customization
and the app is called LidroidSettings.apk - its in v38 which i have
DSA said:
Info - im assuming omegarom uses 23 toggle mod from lidroid - that app is the options app, deleting it will disable 23 toggle customization
and the app is called LidroidSettings.apk
Click to expand...
Click to collapse
Best thing to do till this issue is resolved,I reckon.....anything that is copying your imei and sending it is up to no good imho
DSA said:
Info - im assuming omegarom uses 23 toggle mod from lidroid - that app is the options app, deleting it will disable 23 toggle customization
and the app is called LidroidSettings.apk - its in v38 which i have
Click to expand...
Click to collapse
I checked it with "LogMan logcat" from google play ...
It was pretty lucky that I tested this tool ...
If you want to check your phone you can start LogMan right after a phone reboot ...
Dys66 said:
Hmm, it seems NOT inside my Omega Package.
But I never installed any apps from other locations than XDA or google play.
I will try to find the app in the files i got on my harddisk ...
The app is named "com.lidroid.settings" when I see it right in Titanium
It maintains a database "telocation.db" ... the content seems to be chinese :S
I exported the content for further investigation and will uninstall and delete that crap from my phone ...
Hope that droidwall has blocked the network access :S
Click to expand...
Click to collapse
The apk for Lidroid is in /system/framework
I don't have my GS3 with me today (I also have the mod) so I can't check. I'll shoot a PM over to the Dev who created Lidroid and ask him
the other app it uses is Quicksettings.apk (I believe that's the name off the top of my head)
I don't have the device on my hand to check, but i guess it's because of the Telocation service, i used to hide this tab on my ports, but i didn't remove the services, because i tough it uses the local database.
Anyway i will repack a new one asap.
Edit : i repacked a new one (attached), i removed all telocation dependencies, i had to remove others tab for safety.
wanam said:
I don't have the device on my hand to check, but i guess it's because of the Telocation service, i used to hide this tab on my ports, but i didn't remove the services, because i tough it uses the local database.
Anyway i will repack a new one asap.
Edit : i repacked a new one (attached), i removed all telocation dependencies, i had to remove others tab for safety.
Click to expand...
Click to collapse
Thanks wanam. Is there any need for people to be worried about this from a security perspective?
graffixnyc said:
Thanks wanam. Is there any need for people to be worried about this from a security perspective?
Click to expand...
Click to collapse
In my opinion no need to worry, this service was included in all Lidroid Roms since GS2 days for Chinese users only, i can't confirm that Lidroid save any information remotely.
I need to check the telocation sources, this may give us more information about this issue.
Sent from my GT-N7100 using Tapatalk 2
I just decompiled telocation sources here is the content of the guilty file:
Code:
package com.lidroid.settings.telocation;
import android.content.*;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.google.protobuf.InvalidProtocolBufferException;
import com.lidroid.providers.telocation.DatabaseHelper;
import java.io.InputStream;
import java.net.URL;
// Referenced classes of package com.lidroid.settings.telocation:
// HttpReader
public class UpdateUtils
{
public UpdateUtils(Context context)
{
mOpenHelper = new DatabaseHelper(context, null);
mDeviceId = ((TelephonyManager)context.getSystemService("phone")).getDeviceId();
mContext = context;
}
private void updateMob(Telocation.mob_location mob_location)
{
ContentResolver contentresolver = mContext.getContentResolver();
Uri uri = Uri.parse((new StringBuilder()).append("content://com.lidroid.providers.telocation/mobile/").append(mob_location.getTel()).toString());
Cursor cursor = contentresolver.query(uri, null, null, null, null);
boolean flag;
ContentValues contentvalues;
if(cursor != null && cursor.getCount() > 0)
flag = true;
else
flag = false;
if(cursor != null)
cursor.close();
contentvalues = new ContentValues();
contentvalues.put("_id", mob_location.getTel());
contentvalues.put("location", mob_location.getLocation());
contentvalues.put("areacode", mob_location.getAreacode());
if(flag)
contentresolver.update(uri, contentvalues, null, null);
else
contentresolver.insert(Uri.parse("content://com.lidroid.providers.telocation/mobile"), contentvalues);
}
private void updateSp(Telocation.sp_info sp_info)
{
ContentResolver contentresolver = mContext.getContentResolver();
Uri uri = Uri.parse((new StringBuilder()).append("content://com.lidroid.providers.telocation/sp/").append(sp_info.getTel()).toString());
Cursor cursor = contentresolver.query(uri, null, null, null, null);
boolean flag;
ContentValues contentvalues;
if(cursor != null && cursor.getCount() > 0)
flag = true;
else
flag = false;
if(cursor != null)
cursor.close();
contentvalues = new ContentValues();
contentvalues.put("addr", sp_info.getTel());
contentvalues.put("name", sp_info.getName());
if(flag)
contentresolver.update(uri, contentvalues, null, null);
else
contentresolver.insert(Uri.parse("content://com.lidroid.providers.telocation/sp"), contentvalues);
}
public long upgrade()
{
InputStream inputstream;
HttpReader httpreader;
inputstream = null;
httpreader = null;
Uri uri;
HttpReader httpreader1;
uri = Uri.parse("content://com.lidroid.providers.telocation/ver");
int i = mContext.getContentResolver().update(uri, null, null, null);
[COLOR="Red"]URL url = new URL((new StringBuilder()).append("http://loc.lidroid.com/update/").append(i).append("/").append(Build.DISPLAY).append("/").append(mDeviceId).toString());[/COLOR]
Log.d("xiaoym", (new StringBuilder()).append("http://loc.lidroid.com/update/").append(i).append("/").append(Build.DISPLAY).append("/").append(mDeviceId).toString());
httpreader1 = new HttpReader(url);
Telocation.update update;
int j;
int k;
inputstream = httpreader1.getStream();
update = Telocation.update.parseFrom(inputstream);
j = update.getMobCount();
k = update.getSpCount();
if(update.getMobCount() != 0) goto _L2; else goto _L1
_L1:
int k1 = update.getSpCount();
if(k1 != 0) goto _L2; else goto _L3
_L3:
long l;
l = 0L;
if(inputstream == null)
break MISSING_BLOCK_LABEL_197;
inputstream.close();
if(httpreader1 != null)
httpreader1.close();
_L6:
return l;
_L2:
int i1 = 0;
_L5:
if(i1 >= j)
break; /* Loop/switch isn't completed */
updateMob(update.getMob(i1));
i1++;
if(true) goto _L5; else goto _L4
_L13:
int j1;
for(; j1 < k; j1++)
updateSp(update.getSp(j1));
Uri uri1 = ContentUris.withAppendedId(uri, update.getVersion());
mContext.getContentResolver().update(uri1, null, null, null);
l = j + k;
if(inputstream == null)
break MISSING_BLOCK_LABEL_306;
inputstream.close();
if(httpreader1 != null)
httpreader1.close();
goto _L6
InvalidProtocolBufferException invalidprotocolbufferexception;
invalidprotocolbufferexception;
_L12:
l = -2L;
if(inputstream == null)
break MISSING_BLOCK_LABEL_334;
inputstream.close();
if(httpreader != null)
httpreader.close();
goto _L6
Exception exception4;
exception4;
goto _L6
Exception exception2;
exception2;
_L11:
l = -3L;
if(inputstream == null)
break MISSING_BLOCK_LABEL_365;
inputstream.close();
if(httpreader != null)
httpreader.close();
goto _L6
Exception exception3;
exception3;
goto _L6
Exception exception;
exception;
_L10:
if(inputstream == null)
break MISSING_BLOCK_LABEL_390;
inputstream.close();
if(httpreader != null)
httpreader.close();
_L8:
throw exception;
Exception exception1;
exception1;
if(true) goto _L8; else goto _L7
_L7:
exception;
httpreader = httpreader1;
if(true) goto _L10; else goto _L9
_L9:
Exception exception5;
exception5;
httpreader = httpreader1;
goto _L11
InvalidProtocolBufferException invalidprotocolbufferexception1;
invalidprotocolbufferexception1;
httpreader = httpreader1;
goto _L12
Exception exception6;
exception6;
goto _L6
Exception exception7;
exception7;
goto _L6
_L4:
j1 = 0;
goto _L13
}
public static final long CONNECT_LIDROID_FAILED = -3L;
public static final long INVALID_TELOCATION_DATA = -2L;
public static final long NO_UPDATE = 0L;
public static final long OPEN_WRITABLE_DATABASE_ERROR = -1L;
private Context mContext;
private String mDeviceId;
private DatabaseHelper mOpenHelper;
}
Lidroid uses this class to collect stats about his users build, this classe call a remote service and save the installed build number for each device ID.
For stats purposes? maybe, i think he wouldn't logged it if he want to use it for bad purposes, Lidroid is the only one who can give us more lights about this.
Anyway the new repacked one is safe to use, i will update my toggles threads asap.
Thanks Wanam and all others involved in resolving this :thumbup:
Is it safe for all devices?

[Q] Get primary phone number of android contact : Android Dev

I am trying to fetch the primary number of a contact in Android but not getting the desired result.
Using the following code
Code:
cursor = getActivity().getContentResolver().query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + "=?", new String[] { id }, null);
phoneIdx = cursor.getColumnIndex(Phone.DATA);
if (cursor.moveToFirst()) {
while (cursor.isAfterLast() == false) {
String phoneNumber = cursor.getString(phoneIdx);
Log.d(TAG,"Number:::"+ phoneNumber);
int primary = cursor.getColumnIndex(Phone.IS_PRIMARY);
Log.d(TAG, "primary value:::"+ primary);
allNumbers.add(phoneNumber);
cursor.moveToNext();
}
}
I have a contact with 2 numbers. One of them is set to primary by holding the number for long and choosing "set as default". When I run this code on the said contact, the PHONE.IS_PRIMARY returns 45 for both the numbers.
I wish to know which of the number has been set to default for a contact.

[XPOSED] [KK] [FIX] KitKat BUGS fixer

============== FIXES ==============
1. https://android-review.googlesource.com/#/c/81970/
Head: All service returning START_STICKY do not restart after it is being killed.
Symptom: if you will start heavy application (game, video encode/decode viewing or bad application which occupy lot of resources), android can kill background service, for example Skype or WhatsApp, but will never restart services when resources become free. Need to start application again or even full phone restart.
Affected version: 4.4, 4.4.1, and 4.4.2.
2. https://android-review.googlesource.com/#/c/98918/
Head: If all activities of a given stack were finishing, no activity was marked as front-of-task.
Symptom: if recents has several apps running, clicking BACK button fast to close current activity will bring to front another activity.
Affected version: 4.4.*
Mod does not have any settings activity. Just enabled it in Xposed menu.
INSTRUCTIONS:
if you get boot-loop
1. after phone start go to Xposed and immediately uncheck module.
2. issue command adb logcat > logcat.txt
3. phone will reboot again soon
4. upload logcat somewhere and post link here.
5. After next restart mod will be disabled.
6. Wait when I will publish correction.
Can be downloaded through Xposed Installer or here: http://repo.xposed.info/module/kz.virtex.android.issue63793fix
Source code:
Code:
package kz.virtex.android.issue63793fix;
import android.content.pm.ApplicationInfo;
import android.os.SystemClock;
import android.util.EventLog;
import android.util.Slog;
import com.android.server.am.EventLogTags;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedHelpers;
public class XMain implements IXposedHookZygoteInit
{
@Override
public void initZygote(StartupParam startupParam) throws Throwable
{
final Class<?> ActiveServices = XposedHelpers.findClass("com.android.server.am.ActiveServices", null);
XposedHelpers.findAndHookMethod(ActiveServices, "killServicesLocked", "com.android.server.am.ProcessRecord", "boolean", new XC_MethodReplacement()
{
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable
{
Boolean DEBUG_SERVICE = (Boolean) XposedHelpers.getStaticBooleanField(ActiveServices, "DEBUG_SERVICE");
String TAG = (String) XposedHelpers.getStaticObjectField(ActiveServices, "TAG");
Object app = param.args[0];
boolean allowRestart = (Boolean) param.args[1];
Object services = XposedHelpers.getObjectField(app, "services");
int size = (Integer) XposedHelpers.callMethod(services, "size");
// First clear app state from services.
for (int i = size - 1; i >= 0; i--) {
Object sr = XposedHelpers.callMethod(services, "valueAt", i);
Object stats = XposedHelpers.getObjectField(sr, "stats");
synchronized (XposedHelpers.callMethod(stats, "getBatteryStats")) {
XposedHelpers.callMethod(stats, "stopLaunchedLocked");
}
Object sr_app = XposedHelpers.getObjectField(sr, "app");
Boolean persistent = XposedHelpers.getBooleanField(sr_app, "persistent");
Boolean stopIfKilled = XposedHelpers.getBooleanField(sr, "stopIfKilled");
if (sr_app != null && !persistent && stopIfKilled) {
Object sr_app_services = XposedHelpers.getObjectField(sr_app, "services");
XposedHelpers.callMethod(sr_app_services, "remove", sr);
}
XposedHelpers.setObjectField(sr, "app", null);
XposedHelpers.setObjectField(sr, "isolatedProc", null);
XposedHelpers.setObjectField(sr, "executeNesting", 0);
XposedHelpers.callMethod(sr, "forceClearTracker");
Object mDestroyingServices = XposedHelpers.getObjectField(param.thisObject, "mDestroyingServices");
Boolean check = (Boolean) XposedHelpers.callMethod(mDestroyingServices, "remove", sr);
if (check) {
if (DEBUG_SERVICE)
Slog.v(TAG, "killServices remove destroying " + sr);
}
Object bindings = XposedHelpers.getObjectField(sr, "bindings");
final int numClients = (Integer) XposedHelpers.callMethod(bindings, "size");
for (int bindingi = numClients - 1; bindingi >= 0; bindingi--) {
Object IntentBindRecord = XposedHelpers.callMethod(bindings, "valueAt", bindingi);
if (DEBUG_SERVICE)
Slog.v(TAG, "Killing binding " + IntentBindRecord + ": shouldUnbind=" + XposedHelpers.getObjectField(IntentBindRecord, "hasBound"));
XposedHelpers.setObjectField(IntentBindRecord, "binder", null);
XposedHelpers.setObjectField(IntentBindRecord, "requested", false);
XposedHelpers.setObjectField(IntentBindRecord, "received", false);
XposedHelpers.setObjectField(IntentBindRecord, "hasBound", false);
}
}
// Clean up any connections this application has to other
// services.
Object connections = XposedHelpers.getObjectField(app, "connections");
size = (Integer) XposedHelpers.callMethod(connections, "size");
for (int i = size - 1; i >= 0; i--) {
Object ConnectionRecord = XposedHelpers.callMethod(connections, "valueAt", i);
XposedHelpers.callMethod(param.thisObject, "removeConnectionLocked", ConnectionRecord, app, null);
}
XposedHelpers.callMethod(connections, "clear");
Object smap = XposedHelpers.callMethod(param.thisObject, "getServiceMap", XposedHelpers.getObjectField(app, "userId"));
// Now do remaining service cleanup.
services = XposedHelpers.getObjectField(app, "services");
size = (Integer) XposedHelpers.callMethod(services, "size");
for (int i = size - 1; i >= 0; i--) {
Object sr = XposedHelpers.callMethod(services, "valueAt", i);
Object mServicesByName = XposedHelpers.getObjectField(smap, "mServicesByName");
if (XposedHelpers.callMethod(mServicesByName, "get", XposedHelpers.getObjectField(sr, "name")) != sr) {
Object cur = XposedHelpers.callMethod(mServicesByName, "get", XposedHelpers.getObjectField(sr, "name"));
Slog.wtf(TAG, "Service " + sr + " in process " + app + " not same as in map: " + cur);
Object app_services = XposedHelpers.getObjectField(app, "services");
XposedHelpers.callMethod(app_services, "removeAt", i);
continue;
}
// Any services running in the application may need to be
// placed back in the pending list.
Object serviceInfo = XposedHelpers.getObjectField(sr, "serviceInfo");
Object applicationInfo = XposedHelpers.getObjectField(serviceInfo, "applicationInfo");
if (allowRestart && XposedHelpers.getIntField(sr, "crashCount") >= 2 && (XposedHelpers.getIntField(applicationInfo, "flags") & ApplicationInfo.FLAG_PERSISTENT) == 0) {
Slog.w(TAG, "Service crashed " + XposedHelpers.getIntField(sr, "crashCount") + " times, stopping: " + sr);
EventLog.writeEvent(EventLogTags.AM_SERVICE_CRASHED_TOO_MUCH, XposedHelpers.getObjectField(sr, "userId"), XposedHelpers.getObjectField(sr, "crashCount"), XposedHelpers.getObjectField(sr, "shortName"), XposedHelpers.getObjectField(app, "pid"));
XposedHelpers.callMethod(param.thisObject, "bringDownServiceLocked", sr);
} else if (!allowRestart) {
XposedHelpers.callMethod(param.thisObject, "bringDownServiceLocked", sr);
} else {
boolean canceled = (Boolean) XposedHelpers.callMethod(param.thisObject, "scheduleServiceRestartLocked", sr, true);
// Should the service remain running? Note that in the
// extreme case of so many attempts to deliver a command
// that it failed we also will stop it here.
if (XposedHelpers.getBooleanField(sr, "startRequested") && (XposedHelpers.getBooleanField(sr, "stopIfKilled") || canceled)) {
Object pendingStarts = XposedHelpers.getObjectField(sr, "pendingStarts");
if ((Integer) XposedHelpers.callMethod(pendingStarts, "size") == 0) {
XposedHelpers.setBooleanField(sr, "startRequested", false);
if (XposedHelpers.getObjectField(sr, "tracker") != null) {
Object tracker = XposedHelpers.getObjectField(sr, "tracker");
Object mAm = XposedHelpers.getObjectField(param.thisObject, "mAm");
Object mProcessStats = XposedHelpers.getObjectField(mAm, "mProcessStats");
XposedHelpers.callMethod(tracker, "setStarted", false, XposedHelpers.callMethod(mProcessStats, "getMemFactorLocked"), SystemClock.uptimeMillis());
}
if (!XposedHelpers.getBooleanField(sr, "hasAutoCreateConnections")) {
// Whoops, no reason to restart!
XposedHelpers.callMethod(param.thisObject, "bringDownServiceLocked", sr);
}
}
}
}
}
if (!allowRestart) {
Object app_services = XposedHelpers.getObjectField(app, "services");
XposedHelpers.callMethod(app_services, "clear");
// Make sure there are no more restarting services for this
// process.
Object mRestartingServices = XposedHelpers.getObjectField(param.thisObject, "mRestartingServices");
for (int i = (Integer) XposedHelpers.callMethod(mRestartingServices, "size") - 1; i >= 0; i--) {
Object r = XposedHelpers.callMethod(mRestartingServices, "get", i);
String processName = (String) XposedHelpers.getObjectField(r, "processName");
Object serviceInfo = XposedHelpers.getObjectField(r, "serviceInfo");
Object applicationInfo = XposedHelpers.getObjectField(serviceInfo, "applicationInfo");
Object info = XposedHelpers.getObjectField(app, "info");
if (processName.equals((String) XposedHelpers.getObjectField(app, "processName")) && XposedHelpers.getIntField(applicationInfo, "uid") == XposedHelpers.getIntField(info, "uid")) {
XposedHelpers.callMethod(mRestartingServices, "remove", i);
XposedHelpers.callMethod(param.thisObject, "clearRestartingIfNeededLocked", r);
}
}
Object mPendingServices = XposedHelpers.getObjectField(param.thisObject, "mPendingServices");
for (int i = (Integer) XposedHelpers.callMethod(mPendingServices, "size") - 1; i >= 0; i--) {
Object r = XposedHelpers.callMethod(mPendingServices, "get", i);
String processName = (String) XposedHelpers.getObjectField(r, "processName");
Object serviceInfo = XposedHelpers.getObjectField(r, "serviceInfo");
Object applicationInfo = XposedHelpers.getObjectField(serviceInfo, "applicationInfo");
Object info = XposedHelpers.getObjectField(app, "info");
if (processName.equals((String) XposedHelpers.getObjectField(app, "processName")) && XposedHelpers.getIntField(applicationInfo, "uid") == XposedHelpers.getIntField(info, "uid")) {
XposedHelpers.callMethod(mPendingServices, "remove", i);
}
}
}
// Make sure we have no more records on the stopping list.
Object mDestroyingServices = XposedHelpers.getObjectField(param.thisObject, "mDestroyingServices");
int i = (Integer) XposedHelpers.callMethod(mDestroyingServices, "size");
while (i > 0) {
i--;
Object sr = XposedHelpers.callMethod(mDestroyingServices, "get", i);
if (XposedHelpers.getObjectField(sr, "app") == app) {
XposedHelpers.callMethod(sr, "forceClearTracker");
XposedHelpers.callMethod(mDestroyingServices, "remove", i);
if (DEBUG_SERVICE)
Slog.v(TAG, "killServices remove destroying " + sr);
}
}
Object executingServices = XposedHelpers.getObjectField(app, "executingServices");
XposedHelpers.callMethod(executingServices, "clear");
return null;
}
});
}
}
Perfect. Good work.
Excellent! ^_^ We need more of your kind to fix goggles sloppy work...thanks!
chw9999 said:
Excellent! ^_^ We need more of your kind to fix goggles sloppy work...thanks!
Click to expand...
Click to collapse
just show and I will try )))
Awesome work!
Could you create a module for this fix also? https://android-review.googlesource.com/#/c/98918
a3Dman said:
Awesome work!
Could you create a module for this fix also? https://android-review.googlesource.com/#/c/98918
Click to expand...
Click to collapse
what if we will combine all bugs fixes in one mod?
Beautiful! I had this annoying issue with Skype.
Falseclock said:
what if we will combine all bugs fixes in one mod?
Click to expand...
Click to collapse
Fix working on my S5 Android 4.4.2
Thanks!
Sent from my SM-G900F using XDA Premium 4 mobile app
Hey there! Thank you! This module doesn't change the behaviour of the Google Play Music app when you swipe it from recents on my phone. I've installed it on my phone, and music still stops after clearing the app from recents.
Also, the last few comments on the Google Code issue tracker page say "This has been fixed in 4.4.3. Yay!" and "I just tested on 4.4.4, and can confirm that this appears to be fixed."...
But I'm running 4.4.4 on my Nexus 5, and Play Music still behaves that way. What gives? Any insight?
ZCochrane said:
But I'm running 4.4.4 on my Nexus 5, and Play Music still behaves that way. What gives? Any insight?
Click to expand...
Click to collapse
Affected version: 4.4, 4.4.1, and 4.4.2.
you do not need this mod.
Falseclock said:
Affected version: 4.4, 4.4.1, and 4.4.2.
you do not need this mod.
Click to expand...
Click to collapse
But that's what I'm saying, 4.4.4 is also affected, with Google Play Music behaving in the abnormal way you described.
ZCochrane said:
But that's what I'm saying, 4.4.4 is also affected, with Google Play Music behaving in the abnormal way you described.
Click to expand...
Click to collapse
yep, sorry. this is another issue
and related to 4.4.4
looking for solution
Falseclock said:
yep, sorry. this is another issue
and related to 4.4.4
looking for solution
Click to expand...
Click to collapse
Ooh, cool, gotcha!
Thanks!
ZCochrane said:
Ooh, cool, gotcha!
Thanks!
Click to expand...
Click to collapse
https://android-review.googlesource.com/#/c/53871/
will try to fix... too much coding (((
725 lines of code... looks almost impossible
a3Dman said:
Awesome work!
Could you create a module for this fix also? https://android-review.googlesource.com/#/c/98918
Click to expand...
Click to collapse
tonight :good:
Is HTC Sense 5.5 with Android 4.4.2 also affected?
[size=-2]Send with much love & Android. ( HTC One M7 )[/size]
n0j0e said:
Is HTC Sense 5.5 with Android 4.4.2 also affected?
Click to expand...
Click to collapse
yes
ZCochrane said:
Ooh, cool, gotcha!
Thanks!
Click to expand...
Click to collapse
on HTC 4.4.2 this bug already fixed so can't check by myself
please try with Google Music.
if you will get boot-loop - see OP
Falseclock said:
on HTC 4.4.2 this bug already fixed so can't check by myself
please try with Google Music.
if you will get boot-loop - see OP
Click to expand...
Click to collapse
That almost did it!! You're on the right track though, amazing!!
Now this happens:
1) Open Music & start song playback
2) Open recents, swipe Music away, then tap Home button.
3) Music keeps playing! (YAY!)
4) Open music app again, but do nothing in it. (Notification icon is removed, but the notification icon was never displayed when the app is open, so it's normal behaviour)
5) Tap Recent Tasks, music stops instantly, even without swiping the app away, notification icon stays gone.
6) (interestingly, at this stage, tapping the app's recent thumbnail doesn't open the app, nor does the Back button)
Problem is a step 5.
It's pretty cool to see this problem get attention, though.

Categories

Resources