From 427f1625191110b86e2bf7ceef76211fd865ff10 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Wed, 8 Jul 2015 13:37:22 -0700 Subject: [PATCH] mv //sky/services/intents //sky/services/activity This interface is growing to expose many activity-related functions, more than just intents. R=eseidel@chromium.org, eseidel@google.com Review URL: https://codereview.chromium.org/1223053002 . --- BUILD.gn | 2 +- sdk/example/demo_launcher/apk/BUILD.gn | 4 +-- .../domokit/sky/demo/SkyDemoApplication.java | 8 +++--- sdk/lib/mojo/activity.dart | 21 ++++++++------- services/{intents => activity}/BUILD.gn | 10 +++---- .../intents.mojom => activity/activity.mojom} | 4 +-- .../org/domokit/activity/ActivityImpl.java} | 27 +++++++++---------- shell/BUILD.gn | 4 ++- .../org/domokit/sky/shell/SkyActivity.java | 4 +-- viewer/BUILD.gn | 2 +- 10 files changed, 44 insertions(+), 42 deletions(-) rename services/{intents => activity}/BUILD.gn (77%) rename services/{intents/intents.mojom => activity/activity.mojom} (95%) rename services/{intents/src/org/domokit/intents/ActivityManagerImpl.java => activity/src/org/domokit/activity/ActivityImpl.java} (76%) diff --git a/BUILD.gn b/BUILD.gn index 8955524c8..d044f61b4 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -30,7 +30,7 @@ group("sky_apk") { ] if (is_android) { - deps += [ "//sky/services/intents" ] + deps += [ "//sky/services/activity" ] } if (is_linux) { diff --git a/sdk/example/demo_launcher/apk/BUILD.gn b/sdk/example/demo_launcher/apk/BUILD.gn index 7e9311092..07279cb75 100644 --- a/sdk/example/demo_launcher/apk/BUILD.gn +++ b/sdk/example/demo_launcher/apk/BUILD.gn @@ -21,8 +21,8 @@ android_library("java") { "//mojo/services/sensors/public/interfaces:interfaces_java", "//services/keyboard", "//services/sensors:sensors_lib", - "//sky/services/intents:intents_lib", - "//sky/services/intents:interfaces_java", + "//sky/services/activity:activity_lib", + "//sky/services/activity:interfaces_java", "//sky/services/media:media_lib", "//sky/services/media:interfaces_java", "//sky/shell:java", diff --git a/sdk/example/demo_launcher/apk/org/domokit/sky/demo/SkyDemoApplication.java b/sdk/example/demo_launcher/apk/org/domokit/sky/demo/SkyDemoApplication.java index d01975b9a..596e67317 100644 --- a/sdk/example/demo_launcher/apk/org/domokit/sky/demo/SkyDemoApplication.java +++ b/sdk/example/demo_launcher/apk/org/domokit/sky/demo/SkyDemoApplication.java @@ -10,11 +10,11 @@ import org.chromium.mojo.keyboard.KeyboardServiceImpl; import org.chromium.mojo.sensors.SensorServiceImpl; import org.chromium.mojo.system.Core; import org.chromium.mojo.system.MessagePipeHandle; -import org.chromium.mojom.intents.ActivityManager; +import org.chromium.mojom.activity.Activity; import org.chromium.mojom.keyboard.KeyboardService; import org.chromium.mojom.media.MediaService; import org.chromium.mojom.sensors.SensorService; -import org.domokit.intents.ActivityManagerImpl; +import org.domokit.activity.ActivityImpl; import org.domokit.media.MediaServiceImpl; import org.domokit.sky.shell.ResourceExtractor; import org.domokit.sky.shell.ServiceFactory; @@ -56,10 +56,10 @@ public class SkyDemoApplication extends SkyApplication { } }); - registry.register(ActivityManager.MANAGER.getName(), new ServiceFactory() { + registry.register(Activity.MANAGER.getName(), new ServiceFactory() { @Override public void connectToService(Context context, Core core, MessagePipeHandle pipe) { - ActivityManager.MANAGER.bind(new ActivityManagerImpl(), pipe); + Activity.MANAGER.bind(new ActivityImpl(), pipe); } }); diff --git a/sdk/lib/mojo/activity.dart b/sdk/lib/mojo/activity.dart index 6c6fe6e7e..4a5ddf3df 100644 --- a/sdk/lib/mojo/activity.dart +++ b/sdk/lib/mojo/activity.dart @@ -3,32 +3,33 @@ // found in the LICENSE file. import 'dart:sky'; -import 'package:mojom/intents/intents.mojom.dart'; +import 'package:mojom/activity/activity.mojom.dart'; import 'package:sky/mojo/shell.dart' as shell; -export 'package:mojom/intents/intents.mojom.dart' show Intent, ComponentName, StringExtra; + +export 'package:mojom/activity/activity.mojom.dart' show Intent, ComponentName, StringExtra; const int NEW_DOCUMENT = 0x00080000; const int NEW_TASK = 0x10000000; const int MULTIPLE_TASK = 0x08000000; -ActivityManagerProxy _initActivityManager() { - ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound(); - shell.requestService('mojo:sky_viewer', activityManager); - return activityManager; +ActivityProxy _initActivity() { + ActivityProxy activity = new ActivityProxy.unbound(); + shell.requestService('mojo:sky_viewer', activity); + return activity; } -final ActivityManagerProxy _activityManager = _initActivityManager(); +final ActivityProxy _activity = _initActivity(); Color _cachedPrimaryColor; String _cachedLabel; void finishCurrentActivity() { - _activityManager.ptr.finishCurrentActivity(); + _activity.ptr.finishCurrentActivity(); } void startActivity(Intent intent) { - _activityManager.ptr.startActivity(intent); + _activity.ptr.startActivity(intent); } void updateTaskDescription(String label, Color color) { @@ -42,5 +43,5 @@ void updateTaskDescription(String label, Color color) { ..label = label ..primaryColor = (color != null ? color.value : null); - _activityManager.ptr.setTaskDescription(description); + _activity.ptr.setTaskDescription(description); } diff --git a/services/intents/BUILD.gn b/services/activity/BUILD.gn similarity index 77% rename from services/intents/BUILD.gn rename to services/activity/BUILD.gn index 52bf6692f..ee5dbf3b5 100644 --- a/services/intents/BUILD.gn +++ b/services/activity/BUILD.gn @@ -4,7 +4,7 @@ import("//mojo/public/tools/bindings/mojom.gni") -group("intents") { +group("activity") { testonly = true deps = [ @@ -12,7 +12,7 @@ group("intents") { ] if (is_android) { - deps += [ ":intents_lib" ] + deps += [ ":activity_lib" ] } } @@ -20,8 +20,8 @@ if (is_android) { import("//build/config/android/config.gni") import("//build/config/android/rules.gni") - android_library("intents_lib") { - java_files = [ "src/org/domokit/intents/ActivityManagerImpl.java" ] + android_library("activity_lib") { + java_files = [ "src/org/domokit/activity/ActivityImpl.java" ] deps = [ "//base:base_java", @@ -34,6 +34,6 @@ if (is_android) { mojom("interfaces") { sources = [ - "intents.mojom", + "activity.mojom", ] } diff --git a/services/intents/intents.mojom b/services/activity/activity.mojom similarity index 95% rename from services/intents/intents.mojom rename to services/activity/activity.mojom index bf6286fe2..440176d53 100644 --- a/services/intents/intents.mojom +++ b/services/activity/activity.mojom @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -module intents; +module activity; struct StringExtra { string name; @@ -31,7 +31,7 @@ struct TaskDescription { // have a higher-level abstraction here? Do we want a collection // of services that only work on specific platforms? We need to // figure out how to rationalize this interface across platforms. -interface ActivityManager { +interface Activity { startActivity(Intent intent); finishCurrentActivity(); setTaskDescription(TaskDescription description); diff --git a/services/intents/src/org/domokit/intents/ActivityManagerImpl.java b/services/activity/src/org/domokit/activity/ActivityImpl.java similarity index 76% rename from services/intents/src/org/domokit/intents/ActivityManagerImpl.java rename to services/activity/src/org/domokit/activity/ActivityImpl.java index 70b4ca9e6..a61971a6e 100644 --- a/services/intents/src/org/domokit/intents/ActivityManagerImpl.java +++ b/services/activity/src/org/domokit/activity/ActivityImpl.java @@ -2,30 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.domokit.intents; +package org.domokit.activity; -import android.app.Activity; import android.content.ActivityNotFoundException; import android.net.Uri; import android.util.Log; import org.chromium.mojo.system.MojoException; -import org.chromium.mojom.intents.ActivityManager; -import org.chromium.mojom.intents.ComponentName; -import org.chromium.mojom.intents.Intent; -import org.chromium.mojom.intents.StringExtra; +import org.chromium.mojom.activity.Activity; +import org.chromium.mojom.activity.ComponentName; +import org.chromium.mojom.activity.Intent; +import org.chromium.mojom.activity.StringExtra; +import org.chromium.mojom.activity.TaskDescription; /** - * Android implementation of ActivityManager. + * Android implementation of Activity. */ -public class ActivityManagerImpl implements ActivityManager { - private static final String TAG = "ActivityManagerImpl"; - private static Activity sCurrentActivity; +public class ActivityImpl implements Activity { + private static final String TAG = "ActivityImpl"; + private static android.app.Activity sCurrentActivity; - public ActivityManagerImpl() { + public ActivityImpl() { } - public static void setCurrentActivity(Activity activity) { + public static void setCurrentActivity(android.app.Activity activity) { sCurrentActivity = activity; } @@ -79,8 +79,7 @@ public class ActivityManagerImpl implements ActivityManager { } @Override - public void setTaskDescription( - org.chromium.mojom.intents.TaskDescription description) { + public void setTaskDescription(TaskDescription description) { if (sCurrentActivity == null) { return; } diff --git a/shell/BUILD.gn b/shell/BUILD.gn index af5b10348..c4a0f508f 100644 --- a/shell/BUILD.gn +++ b/shell/BUILD.gn @@ -115,11 +115,13 @@ if (is_android) { "//mojo/public/interfaces/application:application_java", "//mojo/public/java:bindings", "//mojo/public/java:system", + "//mojo/services/keyboard/public/interfaces:interfaces_java", "//mojo/services/network/public/interfaces:interfaces_java", "//services/keyboard", + "//sky/services/activity:activity_lib", + "//sky/services/activity:interfaces_java", "//sky/services/engine:engine_java", "//sky/services/oknet", - "//sky/services/intents:intents_lib", ] } diff --git a/shell/android/org/domokit/sky/shell/SkyActivity.java b/shell/android/org/domokit/sky/shell/SkyActivity.java index 1e13dd36f..c29e4647e 100644 --- a/shell/android/org/domokit/sky/shell/SkyActivity.java +++ b/shell/android/org/domokit/sky/shell/SkyActivity.java @@ -12,7 +12,7 @@ import android.view.WindowManager; import org.chromium.base.PathUtils; -import org.domokit.intents.ActivityManagerImpl; +import org.domokit.activity.ActivityImpl; import java.io.File; @@ -44,7 +44,7 @@ public class SkyActivity extends Activity { SkyMain.ensureInitialized(getApplicationContext()); mView = new PlatformViewAndroid(this, edgeDims); - ActivityManagerImpl.setCurrentActivity(this); + ActivityImpl.setCurrentActivity(this); setContentView(mView); mTracingController = new TracingController(this); diff --git a/viewer/BUILD.gn b/viewer/BUILD.gn index 6e4a39997..c90e753b3 100644 --- a/viewer/BUILD.gn +++ b/viewer/BUILD.gn @@ -52,7 +52,7 @@ mojo_native_application("viewer") { "//skia", "//sky/engine", "//sky/engine/tonic", - "//sky/services/intents:interfaces", + "//sky/services/activity:interfaces", "//sky/services/platform", "//sky/services/testing", "//sky/shell/dart", -- GitLab