Merge "Use connected boolean as NLS does vs IBinder" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
23dcdcefde
@@ -77,6 +77,7 @@ public abstract class ConditionProviderService extends Service {
|
|||||||
|
|
||||||
private Provider mProvider;
|
private Provider mProvider;
|
||||||
private INotificationManager mNoMan;
|
private INotificationManager mNoMan;
|
||||||
|
boolean mIsConnected;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link Intent} that must be declared as handled by the service.
|
* The {@link Intent} that must be declared as handled by the service.
|
||||||
@@ -179,7 +180,7 @@ public abstract class ConditionProviderService extends Service {
|
|||||||
try {
|
try {
|
||||||
noMan.requestUnbindProvider(mProvider);
|
noMan.requestUnbindProvider(mProvider);
|
||||||
// Disable future messages.
|
// Disable future messages.
|
||||||
mProvider = null;
|
mIsConnected = false;
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
throw ex.rethrowFromSystemServer();
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
@@ -233,16 +234,16 @@ public abstract class ConditionProviderService extends Service {
|
|||||||
*/
|
*/
|
||||||
@TestApi
|
@TestApi
|
||||||
public boolean isBound() {
|
public boolean isBound() {
|
||||||
if (mProvider == null) {
|
if (!mIsConnected) {
|
||||||
Log.w(TAG, "Condition provider service not yet bound.");
|
Log.w(TAG, "Condition provider service not yet bound.");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return mIsConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class Provider extends IConditionProvider.Stub {
|
private final class Provider extends IConditionProvider.Stub {
|
||||||
@Override
|
@Override
|
||||||
public void onConnected() {
|
public void onConnected() {
|
||||||
|
mIsConnected = true;
|
||||||
mHandler.obtainMessage(H.ON_CONNECTED).sendToTarget();
|
mHandler.obtainMessage(H.ON_CONNECTED).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +266,7 @@ public abstract class ConditionProviderService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
String name = null;
|
String name = null;
|
||||||
if (!isBound()) {
|
if (!mIsConnected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user