| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.physicalweb; | 5 package org.chromium.chrome.browser.physicalweb; |
| 6 | 6 |
| 7 import android.content.SharedPreferences; | 7 import android.content.SharedPreferences; |
| 8 import android.os.Build; | 8 import android.os.Build; |
| 9 | 9 |
| 10 import org.chromium.base.ContextUtils; | 10 import org.chromium.base.ContextUtils; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 && locationUtils.isSystemLocationSettingEnabled()) { | 63 && locationUtils.isSystemLocationSettingEnabled()) { |
| 64 new NearbyBackgroundSubscription(NearbySubscription.SUBSCRIBE, new R
unnable() { | 64 new NearbyBackgroundSubscription(NearbySubscription.SUBSCRIBE, new R
unnable() { |
| 65 @Override | 65 @Override |
| 66 public void run() { | 66 public void run() { |
| 67 // We need to clear the list of nearby URLs so that they can
be repopulated by | 67 // We need to clear the list of nearby URLs so that they can
be repopulated by |
| 68 // the new subscription, but we don't know whether we are al
ready subscribed, so | 68 // the new subscription, but we don't know whether we are al
ready subscribed, so |
| 69 // we need to pass a callback so that we can clear as soon a
s we are | 69 // we need to pass a callback so that we can clear as soon a
s we are |
| 70 // resubscribed. | 70 // resubscribed. |
| 71 UrlManager.getInstance().clearNearbyUrls(); | 71 UrlManager.getInstance().clearNearbyUrls(); |
| 72 } | 72 } |
| 73 }); | 73 }).run(); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * Stop the Physical Web feature. | 78 * Stop the Physical Web feature. |
| 79 */ | 79 */ |
| 80 public static void stopPhysicalWeb() { | 80 public static void stopPhysicalWeb() { |
| 81 new NearbyBackgroundSubscription(NearbySubscription.UNSUBSCRIBE, new Run
nable() { | 81 new NearbyBackgroundSubscription(NearbySubscription.UNSUBSCRIBE, new Run
nable() { |
| 82 @Override | 82 @Override |
| 83 public void run() { | 83 public void run() { |
| 84 // This isn't absolutely necessary, but it's nice to clean up al
l our shared prefs. | 84 // This isn't absolutely necessary, but it's nice to clean up al
l our shared prefs. |
| 85 UrlManager.getInstance().clearAllUrls(); | 85 UrlManager.getInstance().clearAllUrls(); |
| 86 } | 86 } |
| 87 }); | 87 }).run(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * Returns true if we should fire notifications regardless of the existence
of other Physical | 91 * Returns true if we should fire notifications regardless of the existence
of other Physical |
| 92 * Web clients. | 92 * Web clients. |
| 93 * This method is for use when the native library is not available. | 93 * This method is for use when the native library is not available. |
| 94 */ | 94 */ |
| 95 public static boolean shouldIgnoreOtherClients() { | 95 public static boolean shouldIgnoreOtherClients() { |
| 96 return ContextUtils.getAppSharedPreferences().getBoolean(PREF_IGNORE_OTH
ER_CLIENTS, false); | 96 return ContextUtils.getAppSharedPreferences().getBoolean(PREF_IGNORE_OTH
ER_CLIENTS, false); |
| 97 } | 97 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 128 ContextUtils.getAppSharedPreferences().edit() | 128 ContextUtils.getAppSharedPreferences().edit() |
| 129 .putBoolean(PREF_IGNORE_OTHER_CLIENTS, ignoreOtherClients) | 129 .putBoolean(PREF_IGNORE_OTHER_CLIENTS, ignoreOtherClients) |
| 130 .apply(); | 130 .apply(); |
| 131 startPhysicalWeb(); | 131 startPhysicalWeb(); |
| 132 PhysicalWebUma.uploadDeferredMetrics(); | 132 PhysicalWebUma.uploadDeferredMetrics(); |
| 133 } else { | 133 } else { |
| 134 stopPhysicalWeb(); | 134 stopPhysicalWeb(); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 } | 137 } |
| OLD | NEW |