Merge "Enabled Content Capture in Service" into rvc-dev am: e081caae5f
Change-Id: I6e32b1759f5d3a40ee9e3f28374b7446026773c8
This commit is contained in:
@@ -34,6 +34,7 @@ import android.os.Build;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.contentcapture.ContentCaptureManager;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -306,7 +307,8 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
* {@sample development/samples/ApiDemos/src/com/example/android/apis/app/MessengerServiceActivities.java
|
* {@sample development/samples/ApiDemos/src/com/example/android/apis/app/MessengerServiceActivities.java
|
||||||
* bind}
|
* bind}
|
||||||
*/
|
*/
|
||||||
public abstract class Service extends ContextWrapper implements ComponentCallbacks2 {
|
public abstract class Service extends ContextWrapper implements ComponentCallbacks2,
|
||||||
|
ContentCaptureManager.ContentCaptureClient {
|
||||||
private static final String TAG = "Service";
|
private static final String TAG = "Service";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -817,6 +819,14 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
|
|||||||
writer.println("nothing to dump");
|
writer.println("nothing to dump");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void attachBaseContext(Context newBase) {
|
||||||
|
super.attachBaseContext(newBase);
|
||||||
|
if (newBase != null) {
|
||||||
|
newBase.setContentCaptureOptions(getContentCaptureOptions());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------ Internal API ------------------
|
// ------------------ Internal API ------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -835,6 +845,8 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
|
|||||||
mActivityManager = (IActivityManager)activityManager;
|
mActivityManager = (IActivityManager)activityManager;
|
||||||
mStartCompatibility = getApplicationInfo().targetSdkVersion
|
mStartCompatibility = getApplicationInfo().targetSdkVersion
|
||||||
< Build.VERSION_CODES.ECLAIR;
|
< Build.VERSION_CODES.ECLAIR;
|
||||||
|
|
||||||
|
setContentCaptureOptions(application.getContentCaptureOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -849,6 +861,18 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
|
|||||||
return mClassName;
|
return mClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
public final ContentCaptureManager.ContentCaptureClient getContentCaptureClient() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
public final ComponentName contentCaptureClientGetComponentName() {
|
||||||
|
return new ComponentName(this, mClassName);
|
||||||
|
}
|
||||||
|
|
||||||
// set by the thread after the constructor and before onCreate(Bundle icicle) is called.
|
// set by the thread after the constructor and before onCreate(Bundle icicle) is called.
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
private ActivityThread mThread = null;
|
private ActivityThread mThread = null;
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package com.android.server.notification;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.service.notification.Condition;
|
import android.service.notification.Condition;
|
||||||
@@ -45,7 +47,7 @@ public class ScheduleConditionProviderTest extends UiServiceTestCase {
|
|||||||
null, // ActivityThread not actually used in Service
|
null, // ActivityThread not actually used in Service
|
||||||
ScheduleConditionProvider.class.getName(),
|
ScheduleConditionProvider.class.getName(),
|
||||||
null, // token not needed when not talking with the activity manager
|
null, // token not needed when not talking with the activity manager
|
||||||
null,
|
mock(Application.class),
|
||||||
null // mocked services don't talk with the activity manager
|
null // mocked services don't talk with the activity manager
|
||||||
);
|
);
|
||||||
service.onCreate();
|
service.onCreate();
|
||||||
|
|||||||
Reference in New Issue
Block a user