Merged PR 14712: Fix bad merge and remove a few uneeded references to Rome
Fix bad merge and remove a few uneeded references to Rome
This commit is contained in:
Родитель
777b2bc131
Коммит
8912bbdb0f
|
@ -74,7 +74,7 @@ public class Account {
|
|||
// region public instance methods
|
||||
/**
|
||||
* Perform all actions required to have this account signed in, added to the
|
||||
* ConnectedDevicesPlatform.AccountManager and registered with the Rome platform.
|
||||
* ConnectedDevicesPlatform.AccountManager and registered with the platform.
|
||||
* @param context Application context
|
||||
* @return The async result for this operation
|
||||
*/
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
*/
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
|
||||
package com.microsoft.connecteddevices.graphnotifications;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
import com.google.firebase.iid.InstanceIdResult;
|
||||
import com.google.firebase.messaging.FirebaseMessagingService;
|
||||
import com.google.firebase.messaging.RemoteMessage;
|
||||
|
||||
import com.microsoft.connecteddevices.ConnectedDevicesNotification;
|
||||
import com.microsoft.connecteddevices.ConnectedDevicesPlatform;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -25,15 +22,13 @@ import java.util.Map;
|
|||
*/
|
||||
public class FCMListenerService extends FirebaseMessagingService {
|
||||
private static final String TAG = "FCMListenerService";
|
||||
|
||||
private static final String RegistrationComplete = "registrationComplete";
|
||||
private static final String REGISTRATION_COMPLETE = "registrationComplete";
|
||||
private static final String TOKEN = "TOKEN";
|
||||
|
||||
private static String s_previousToken = null;
|
||||
private static String sPreviousToken = "";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
PlatformManager.getInstance().createNotificationReceiver(this);
|
||||
FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(task -> {
|
||||
if (task.isSuccessful()) {
|
||||
String token = task.getResult().getToken();
|
||||
|
@ -45,38 +40,37 @@ public class FCMListenerService extends FirebaseMessagingService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check whether it's a rome notification or not.
|
||||
* If it is a rome notification,
|
||||
* Check whether it's a ConnectedDevices notification or not.
|
||||
* If it is a ConnectedDevices notification,
|
||||
* It will notify the apps with the information in the notification.
|
||||
* @param message FCM class for messaging with a from a data field.
|
||||
*/
|
||||
@Override
|
||||
public void onMessageReceived(RemoteMessage message) {
|
||||
Log.d(TAG, "From: " + message.getFrom());
|
||||
Log.d(TAG, "FCM notification received from: " + message.getFrom());
|
||||
Map data = message.getData();
|
||||
ConnectedDevicesPlatform platform = ensurePlatformInitialized();
|
||||
platform.processNotification(data);
|
||||
ConnectedDevicesNotification notification = ConnectedDevicesNotification.tryParse(data);
|
||||
|
||||
if (notification != null) {
|
||||
try {
|
||||
ConnectedDevicesPlatform platform = ConnectedDevicesManager.getConnectedDevicesManager(getApplicationContext()).getPlatform();
|
||||
|
||||
// NOTE: it may be useful to attach completion to this async in order to know when the notification is done being processed.
|
||||
// This would be a good time to stop a background service or otherwise cleanup.
|
||||
platform.processNotificationAsync(notification);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to process FCM notification" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewToken(String token) {
|
||||
if (token != null && !token.equals(s_previousToken)) {
|
||||
s_previousToken = token;
|
||||
Intent registrationComplete = new Intent(RegistrationComplete);
|
||||
if (token != null && !token.equals(sPreviousToken)) {
|
||||
sPreviousToken = token;
|
||||
Intent registrationComplete = new Intent(REGISTRATION_COMPLETE);
|
||||
registrationComplete.putExtra(TOKEN, token);
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized ConnectedDevicesPlatform ensurePlatformInitialized() {
|
||||
// First see if we have an existing platform
|
||||
ConnectedDevicesPlatform platform = PlatformManager.getInstance().getPlatform();
|
||||
if (platform != null) {
|
||||
return platform;
|
||||
}
|
||||
|
||||
// No existing platform, so we have to create our own
|
||||
return PlatformManager.getInstance().createPlatform(getApplicationContext());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ import static android.content.Intent.ACTION_SEND;
|
|||
import static android.content.Intent.ACTION_SEND_MULTIPLE;
|
||||
|
||||
/*
|
||||
* Wrapper to hold the Rome ConnectedDevicesAccount and RemoteSystemWatcher,
|
||||
* Wrapper to hold the ConnectedDevicesAccount and RemoteSystemWatcher,
|
||||
* as well as additional information required for NearShare.
|
||||
* Verification:
|
||||
* 1. Discovery: Launch the NearShare App and select check box "Spatially Proximal"
|
||||
|
|
|
@ -90,7 +90,7 @@ public class Account {
|
|||
// region public instance methods
|
||||
/**
|
||||
* Perform all actions required to have this account signed in, added to the
|
||||
* ConnectedDevicesPlatform.AccountManager and registered with the Rome platform.
|
||||
* ConnectedDevicesPlatform.AccountManager and registered with the platform.
|
||||
* @param context Application context
|
||||
* @return The async result for this operation
|
||||
*/
|
||||
|
|
|
@ -76,7 +76,7 @@ abstract class BaseFragment extends Fragment {
|
|||
}
|
||||
|
||||
/**
|
||||
* A shared format to handle all exceptions thrown by the Rome API.
|
||||
* A shared format to handle all exceptions thrown by ConnectedDevices APIs.
|
||||
* @param api Function/Class name called which threw
|
||||
* @param e The throwable exception object
|
||||
*/
|
||||
|
|
|
@ -145,7 +145,7 @@ public class LaunchFragment extends BaseFragment {
|
|||
}
|
||||
|
||||
/**
|
||||
* Responsible for calling into the Rome API to launch the given URI and provides
|
||||
* Responsible for calling into the RemoteSystems API to launch the given URI and provides
|
||||
* the logic to handle the RemoteLaunchUriStatus response.
|
||||
* @param uri URI to launch
|
||||
* @param system The RemoteSystemAppWrapper target for the launch URI request
|
||||
|
|
|
@ -21,7 +21,7 @@ public class SampleGcmListenerService extends GcmListenerService {
|
|||
private final String TAG = SampleGcmListenerService.class.getName();
|
||||
|
||||
/**
|
||||
* If it is a rome notification,
|
||||
* If it is a ConnectedDevices notification,
|
||||
* It will notify the apps with the information in the notification.
|
||||
* @param from describes message sender.
|
||||
* @param data message data as String key/value pairs.
|
||||
|
|
Загрузка…
Ссылка в новой задаче