Loading api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -41102,6 +41102,7 @@ package android.service.settings.suggestions { method public android.os.IBinder onBind(android.content.Intent); method public abstract java.util.List<android.service.settings.suggestions.Suggestion> onGetSuggestions(); method public abstract void onSuggestionDismissed(android.service.settings.suggestions.Suggestion); method public abstract void onSuggestionLaunched(android.service.settings.suggestions.Suggestion); } } core/java/android/service/settings/suggestions/ISuggestionService.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -17,4 +17,10 @@ interface ISuggestionService { * calls. */ void dismissSuggestion(in Suggestion suggestion) = 2; /** * This is the opposite signal to {@link #dismissSuggestion}, indicating a suggestion has been * launched. */ void launchSuggestion(in Suggestion suggestion) = 3; } No newline at end of file core/java/android/service/settings/suggestions/SuggestionService.java +15 −2 Original line number Diff line number Diff line Loading @@ -54,6 +54,14 @@ public abstract class SuggestionService extends Service { } onSuggestionDismissed(suggestion); } @Override public void launchSuggestion(Suggestion suggestion) { if (DEBUG) { Log.d(TAG, "launchSuggestion() " + getPackageName()); } onSuggestionLaunched(suggestion); } }; } Loading @@ -65,7 +73,12 @@ public abstract class SuggestionService extends Service { /** * Dismiss a suggestion. The suggestion will not be included in future * {@link #onGetSuggestions()} calls. * @param suggestion */ public abstract void onSuggestionDismissed(Suggestion suggestion); /** * This is the opposite signal to {@link #onSuggestionDismissed}, indicating a suggestion has * been launched. */ public abstract void onSuggestionLaunched(Suggestion suggestion); } core/tests/coretests/src/android/service/settings/suggestions/MockSuggestionService.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,11 +16,23 @@ package android.service.settings.suggestions; import android.support.annotation.VisibleForTesting; import java.util.ArrayList; import java.util.List; public class MockSuggestionService extends SuggestionService { @VisibleForTesting static boolean sOnSuggestionLaunchedCalled; @VisibleForTesting static boolean sOnSuggestionDismissedCalled; public static void reset() { sOnSuggestionLaunchedCalled = false; sOnSuggestionDismissedCalled = false; } @Override public List<Suggestion> onGetSuggestions() { final List<Suggestion> data = new ArrayList<>(); Loading @@ -34,5 +46,11 @@ public class MockSuggestionService extends SuggestionService { @Override public void onSuggestionDismissed(Suggestion suggestion) { sOnSuggestionDismissedCalled = true; } @Override public void onSuggestionLaunched(Suggestion suggestion) { sOnSuggestionLaunchedCalled = true; } } core/tests/coretests/src/android/service/settings/suggestions/SuggestionServiceTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -16,12 +16,17 @@ package android.service.settings.suggestions; import static com.google.common.truth.Truth.assertThat; import android.content.Intent; import android.os.IBinder; import android.os.RemoteException; import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; import android.support.test.rule.ServiceTestRule; import android.support.test.runner.AndroidJUnit4; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; Loading @@ -45,9 +50,36 @@ public class SuggestionServiceTest { MockSuggestionService.class); } @After public void tearUp() { MockSuggestionService.reset(); } @Test public void canStartService() throws TimeoutException { mServiceTestRule.startService(mMockServiceIntent); // Do nothing after starting service. } @Test public void dismissSuggestion_shouldCallImplementation() throws TimeoutException, RemoteException { MockSuggestionService service = new MockSuggestionService(); IBinder binder = mServiceTestRule.bindService(mMockServiceIntent); ISuggestionService serviceBinder = ISuggestionService.Stub.asInterface(binder); serviceBinder.dismissSuggestion(null); assertThat(service.sOnSuggestionDismissedCalled).isTrue(); } @Test public void launchSuggestion_shouldCallImplementation() throws TimeoutException, RemoteException { MockSuggestionService service = new MockSuggestionService(); IBinder binder = mServiceTestRule.bindService(mMockServiceIntent); ISuggestionService serviceBinder = ISuggestionService.Stub.asInterface(binder); serviceBinder.launchSuggestion(null); assertThat(service.sOnSuggestionLaunchedCalled).isTrue(); } } Loading
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -41102,6 +41102,7 @@ package android.service.settings.suggestions { method public android.os.IBinder onBind(android.content.Intent); method public abstract java.util.List<android.service.settings.suggestions.Suggestion> onGetSuggestions(); method public abstract void onSuggestionDismissed(android.service.settings.suggestions.Suggestion); method public abstract void onSuggestionLaunched(android.service.settings.suggestions.Suggestion); } }
core/java/android/service/settings/suggestions/ISuggestionService.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -17,4 +17,10 @@ interface ISuggestionService { * calls. */ void dismissSuggestion(in Suggestion suggestion) = 2; /** * This is the opposite signal to {@link #dismissSuggestion}, indicating a suggestion has been * launched. */ void launchSuggestion(in Suggestion suggestion) = 3; } No newline at end of file
core/java/android/service/settings/suggestions/SuggestionService.java +15 −2 Original line number Diff line number Diff line Loading @@ -54,6 +54,14 @@ public abstract class SuggestionService extends Service { } onSuggestionDismissed(suggestion); } @Override public void launchSuggestion(Suggestion suggestion) { if (DEBUG) { Log.d(TAG, "launchSuggestion() " + getPackageName()); } onSuggestionLaunched(suggestion); } }; } Loading @@ -65,7 +73,12 @@ public abstract class SuggestionService extends Service { /** * Dismiss a suggestion. The suggestion will not be included in future * {@link #onGetSuggestions()} calls. * @param suggestion */ public abstract void onSuggestionDismissed(Suggestion suggestion); /** * This is the opposite signal to {@link #onSuggestionDismissed}, indicating a suggestion has * been launched. */ public abstract void onSuggestionLaunched(Suggestion suggestion); }
core/tests/coretests/src/android/service/settings/suggestions/MockSuggestionService.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,11 +16,23 @@ package android.service.settings.suggestions; import android.support.annotation.VisibleForTesting; import java.util.ArrayList; import java.util.List; public class MockSuggestionService extends SuggestionService { @VisibleForTesting static boolean sOnSuggestionLaunchedCalled; @VisibleForTesting static boolean sOnSuggestionDismissedCalled; public static void reset() { sOnSuggestionLaunchedCalled = false; sOnSuggestionDismissedCalled = false; } @Override public List<Suggestion> onGetSuggestions() { final List<Suggestion> data = new ArrayList<>(); Loading @@ -34,5 +46,11 @@ public class MockSuggestionService extends SuggestionService { @Override public void onSuggestionDismissed(Suggestion suggestion) { sOnSuggestionDismissedCalled = true; } @Override public void onSuggestionLaunched(Suggestion suggestion) { sOnSuggestionLaunchedCalled = true; } }
core/tests/coretests/src/android/service/settings/suggestions/SuggestionServiceTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -16,12 +16,17 @@ package android.service.settings.suggestions; import static com.google.common.truth.Truth.assertThat; import android.content.Intent; import android.os.IBinder; import android.os.RemoteException; import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; import android.support.test.rule.ServiceTestRule; import android.support.test.runner.AndroidJUnit4; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; Loading @@ -45,9 +50,36 @@ public class SuggestionServiceTest { MockSuggestionService.class); } @After public void tearUp() { MockSuggestionService.reset(); } @Test public void canStartService() throws TimeoutException { mServiceTestRule.startService(mMockServiceIntent); // Do nothing after starting service. } @Test public void dismissSuggestion_shouldCallImplementation() throws TimeoutException, RemoteException { MockSuggestionService service = new MockSuggestionService(); IBinder binder = mServiceTestRule.bindService(mMockServiceIntent); ISuggestionService serviceBinder = ISuggestionService.Stub.asInterface(binder); serviceBinder.dismissSuggestion(null); assertThat(service.sOnSuggestionDismissedCalled).isTrue(); } @Test public void launchSuggestion_shouldCallImplementation() throws TimeoutException, RemoteException { MockSuggestionService service = new MockSuggestionService(); IBinder binder = mServiceTestRule.bindService(mMockServiceIntent); ISuggestionService serviceBinder = ISuggestionService.Stub.asInterface(binder); serviceBinder.launchSuggestion(null); assertThat(service.sOnSuggestionLaunchedCalled).isTrue(); } }