Define getLooper() method

The default implementation uses the main looper to handle service
operations. This is generally okay until we have to make network
calls to retrieve resolution data.

Bug: 25119046
Test: manual
Change-Id: I22b0f279e6c1fde21f207578d2930ab4858bbc78
This commit is contained in:
Todd Kennedy
2016-11-18 12:50:28 -08:00
parent 194e4eeb0e
commit 63d7a9dd6a
2 changed files with 9 additions and 1 deletions

View File

@@ -4554,6 +4554,7 @@ package android.app {
public abstract class EphemeralResolverService extends android.app.Service {
ctor public EphemeralResolverService();
method public final void attachBaseContext(android.content.Context);
method public android.os.Looper getLooper();
method public final android.os.IBinder onBind(android.content.Intent);
method public abstract deprecated java.util.List<android.content.pm.EphemeralResolveInfo> onEphemeralResolveInfoList(int[], int);
method public android.content.pm.EphemeralResolveInfo onGetEphemeralIntentFilter(java.lang.String);

View File

@@ -74,10 +74,17 @@ public abstract class EphemeralResolverService extends Service {
throw new IllegalStateException("Must define");
}
/**
* Returns a {@link Looper} to perform service operations on.
*/
public Looper getLooper() {
return getBaseContext().getMainLooper();
}
@Override
public final void attachBaseContext(Context base) {
super.attachBaseContext(base);
mHandler = new ServiceHandler(base.getMainLooper());
mHandler = new ServiceHandler(getLooper());
}
@Override