зеркало из https://github.com/mozilla/gecko-dev.git
Bug 773050 - Decouple base and services: TabReceivedService. r=mcomella
This does a few things: * Move TabReceivedService out of org.mozilla.gecko.sync; * Use the existing Intent.EXTRA_TITLE instead of a custom field; * Refer to the service by name in the command processor, to break a compile time dependency. We'd like a static check that the service was launched but I don't have a good pattern for this across module boundaries yet. --HG-- rename : mobile/android/base/sync/TabReceivedService.java => mobile/android/base/tabqueue/TabReceivedService.java extra : commitid : h6CoTdKSik extra : rebase_source : 4deda00381542d7a3573c6885ee21095b54f656d
This commit is contained in:
Родитель
08e7c504cd
Коммит
b514e910e8
|
@ -500,8 +500,10 @@
|
|||
#include ../services/manifests/HealthReportAndroidManifest_services.xml.in
|
||||
#include ../services/manifests/SyncAndroidManifest_services.xml.in
|
||||
|
||||
<service android:name="org.mozilla.gecko.sync.TabReceivedService"
|
||||
android:exported="false"/>
|
||||
<service
|
||||
android:name="org.mozilla.gecko.tabqueue.TabReceivedService"
|
||||
android:exported="false" />
|
||||
|
||||
|
||||
#ifdef MOZ_ANDROID_SEARCH_ACTIVITY
|
||||
#include ../search/manifests/SearchAndroidManifest_services.xml.in
|
||||
|
|
|
@ -484,4 +484,7 @@ public class BrowserContract {
|
|||
|
||||
public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "suggestedsites");
|
||||
}
|
||||
|
||||
// We refer to the service by name to decouple services from the rest of the code base.
|
||||
public static final String TAB_RECEIVED_SERVICE_CLASS_NAME = "org.mozilla.gecko.tabqueue.TabReceivedService";
|
||||
}
|
||||
|
|
|
@ -472,12 +472,12 @@ gbjar.sources += [
|
|||
'sqlite/SQLiteBridgeException.java',
|
||||
'SuggestClient.java',
|
||||
'SurfaceBits.java',
|
||||
'sync/TabReceivedService.java',
|
||||
'Tab.java',
|
||||
'tabqueue/TabQueueDispatcher.java',
|
||||
'tabqueue/TabQueueHelper.java',
|
||||
'tabqueue/TabQueuePrompt.java',
|
||||
'tabqueue/TabQueueService.java',
|
||||
'tabqueue/TabReceivedService.java',
|
||||
'Tabs.java',
|
||||
'tabs/PrivateTabsPanel.java',
|
||||
'tabs/TabCurve.java',
|
||||
|
|
|
@ -4,23 +4,24 @@
|
|||
|
||||
package org.mozilla.gecko.sync;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.mozilla.gecko.background.common.log.Logger;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.sync.repositories.NullCursorException;
|
||||
import org.mozilla.gecko.sync.repositories.android.ClientsDatabaseAccessor;
|
||||
import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.mozilla.gecko.background.common.log.Logger;
|
||||
import org.mozilla.gecko.sync.repositories.NullCursorException;
|
||||
import org.mozilla.gecko.sync.repositories.android.ClientsDatabaseAccessor;
|
||||
import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
/**
|
||||
* Process commands received from Sync clients.
|
||||
* <p>
|
||||
|
@ -235,7 +236,6 @@ public class CommandProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void displayURI(final List<String> args, final Context context) {
|
||||
// We trust the client sender that these exist.
|
||||
final String uri = args.get(0);
|
||||
|
@ -252,9 +252,10 @@ public class CommandProcessor {
|
|||
title = args.get(2);
|
||||
}
|
||||
|
||||
final Intent sendTabNotificationIntent = new Intent(context, TabReceivedService.class);
|
||||
final Intent sendTabNotificationIntent = new Intent();
|
||||
sendTabNotificationIntent.setClassName(context, BrowserContract.TAB_RECEIVED_SERVICE_CLASS_NAME);
|
||||
sendTabNotificationIntent.setData(Uri.parse(uri));
|
||||
sendTabNotificationIntent.putExtra(TabReceivedService.EXTRA_TITLE, title);
|
||||
context.startService(sendTabNotificationIntent);
|
||||
sendTabNotificationIntent.putExtra(Intent.EXTRA_TITLE, title);
|
||||
final ComponentName componentName = context.startService(sendTabNotificationIntent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,20 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.sync;
|
||||
|
||||
import org.mozilla.gecko.BrowserLocaleManager;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.tabqueue.TabQueueDispatcher;
|
||||
package org.mozilla.gecko.tabqueue;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.util.Log;
|
||||
import org.mozilla.gecko.BrowserLocaleManager;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
|
||||
/**
|
||||
* An IntentService that displays a notification for a tab sent to this device.
|
||||
|
@ -30,8 +29,6 @@ public class TabReceivedService extends IntentService {
|
|||
|
||||
private static final String PREF_NOTIFICATION_ID = "tab_received_notification_id";
|
||||
|
||||
public static final String EXTRA_TITLE = "org.mozilla.gecko.extra.TITLE";
|
||||
|
||||
private static final int MAX_NOTIFICATION_COUNT = 1000;
|
||||
|
||||
public TabReceivedService() {
|
||||
|
@ -52,7 +49,7 @@ public class TabReceivedService extends IntentService {
|
|||
return;
|
||||
}
|
||||
|
||||
final String title = intent.getStringExtra(EXTRA_TITLE);
|
||||
final String title = intent.getStringExtra(Intent.EXTRA_TITLE);
|
||||
String notificationTitle = this.getString(R.string.sync_new_tab);
|
||||
if (title != null) {
|
||||
notificationTitle = notificationTitle.concat(": " + title);
|
||||
|
@ -94,4 +91,3 @@ public class TabReceivedService extends IntentService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче