Merge changes from topic "revert-injectors" into oc-mr1-dev
* changes: Revert "Add API to allow apps more control over instantiation" Revert "Add plugin to swap out recents"
This commit is contained in:
committed by
Android (Google) Code Review
commit
d33fe05c66
@@ -4214,12 +4214,6 @@ package android.app {
|
|||||||
|
|
||||||
public class Application extends android.content.ContextWrapper implements android.content.ComponentCallbacks2 {
|
public class Application extends android.content.ContextWrapper implements android.content.ComponentCallbacks2 {
|
||||||
ctor public Application();
|
ctor public Application();
|
||||||
method public android.app.Activity instantiateActivity(java.lang.ClassLoader, java.lang.String, android.content.Intent);
|
|
||||||
method public android.app.backup.BackupAgent instantiateBackupAgent(java.lang.ClassLoader, java.lang.String);
|
|
||||||
method public android.app.Instrumentation instantiateInstrumentation(java.lang.ClassLoader, java.lang.String);
|
|
||||||
method public android.content.ContentProvider instantiateProvider(java.lang.ClassLoader, java.lang.String);
|
|
||||||
method public android.content.BroadcastReceiver instantiateReceiver(java.lang.ClassLoader, java.lang.String, android.content.Intent);
|
|
||||||
method public android.app.Service instantiateService(java.lang.ClassLoader, java.lang.String, android.content.Intent);
|
|
||||||
method public void onConfigurationChanged(android.content.res.Configuration);
|
method public void onConfigurationChanged(android.content.res.Configuration);
|
||||||
method public void onCreate();
|
method public void onCreate();
|
||||||
method public void onLowMemory();
|
method public void onLowMemory();
|
||||||
|
|||||||
@@ -4378,12 +4378,6 @@ package android.app {
|
|||||||
|
|
||||||
public class Application extends android.content.ContextWrapper implements android.content.ComponentCallbacks2 {
|
public class Application extends android.content.ContextWrapper implements android.content.ComponentCallbacks2 {
|
||||||
ctor public Application();
|
ctor public Application();
|
||||||
method public android.app.Activity instantiateActivity(java.lang.ClassLoader, java.lang.String, android.content.Intent);
|
|
||||||
method public android.app.backup.BackupAgent instantiateBackupAgent(java.lang.ClassLoader, java.lang.String);
|
|
||||||
method public android.app.Instrumentation instantiateInstrumentation(java.lang.ClassLoader, java.lang.String);
|
|
||||||
method public android.content.ContentProvider instantiateProvider(java.lang.ClassLoader, java.lang.String);
|
|
||||||
method public android.content.BroadcastReceiver instantiateReceiver(java.lang.ClassLoader, java.lang.String, android.content.Intent);
|
|
||||||
method public android.app.Service instantiateService(java.lang.ClassLoader, java.lang.String, android.content.Intent);
|
|
||||||
method public void onConfigurationChanged(android.content.res.Configuration);
|
method public void onConfigurationChanged(android.content.res.Configuration);
|
||||||
method public void onCreate();
|
method public void onCreate();
|
||||||
method public void onLowMemory();
|
method public void onLowMemory();
|
||||||
|
|||||||
@@ -4227,12 +4227,6 @@ package android.app {
|
|||||||
|
|
||||||
public class Application extends android.content.ContextWrapper implements android.content.ComponentCallbacks2 {
|
public class Application extends android.content.ContextWrapper implements android.content.ComponentCallbacks2 {
|
||||||
ctor public Application();
|
ctor public Application();
|
||||||
method public android.app.Activity instantiateActivity(java.lang.ClassLoader, java.lang.String, android.content.Intent);
|
|
||||||
method public android.app.backup.BackupAgent instantiateBackupAgent(java.lang.ClassLoader, java.lang.String);
|
|
||||||
method public android.app.Instrumentation instantiateInstrumentation(java.lang.ClassLoader, java.lang.String);
|
|
||||||
method public android.content.ContentProvider instantiateProvider(java.lang.ClassLoader, java.lang.String);
|
|
||||||
method public android.content.BroadcastReceiver instantiateReceiver(java.lang.ClassLoader, java.lang.String, android.content.Intent);
|
|
||||||
method public android.app.Service instantiateService(java.lang.ClassLoader, java.lang.String, android.content.Intent);
|
|
||||||
method public void onConfigurationChanged(android.content.res.Configuration);
|
method public void onConfigurationChanged(android.content.res.Configuration);
|
||||||
method public void onCreate();
|
method public void onCreate();
|
||||||
method public void onLowMemory();
|
method public void onLowMemory();
|
||||||
|
|||||||
@@ -2666,14 +2666,8 @@ public final class ActivityThread {
|
|||||||
Activity activity = null;
|
Activity activity = null;
|
||||||
try {
|
try {
|
||||||
java.lang.ClassLoader cl = appContext.getClassLoader();
|
java.lang.ClassLoader cl = appContext.getClassLoader();
|
||||||
if (appContext.getApplicationContext() instanceof Application) {
|
activity = mInstrumentation.newActivity(
|
||||||
activity = ((Application) appContext.getApplicationContext())
|
cl, component.getClassName(), r.intent);
|
||||||
.instantiateActivity(cl, component.getClassName(), r.intent);
|
|
||||||
}
|
|
||||||
if (activity == null) {
|
|
||||||
activity = mInstrumentation.newActivity(
|
|
||||||
cl, component.getClassName(), r.intent);
|
|
||||||
}
|
|
||||||
StrictMode.incrementExpectedActivityCount(activity.getClass());
|
StrictMode.incrementExpectedActivityCount(activity.getClass());
|
||||||
r.intent.setExtrasClassLoader(cl);
|
r.intent.setExtrasClassLoader(cl);
|
||||||
r.intent.prepareToEnterProcess();
|
r.intent.prepareToEnterProcess();
|
||||||
@@ -3169,8 +3163,7 @@ public final class ActivityThread {
|
|||||||
data.intent.setExtrasClassLoader(cl);
|
data.intent.setExtrasClassLoader(cl);
|
||||||
data.intent.prepareToEnterProcess();
|
data.intent.prepareToEnterProcess();
|
||||||
data.setExtrasClassLoader(cl);
|
data.setExtrasClassLoader(cl);
|
||||||
receiver = instantiate(cl, component, data.intent, app,
|
receiver = (BroadcastReceiver)cl.loadClass(component).newInstance();
|
||||||
Application::instantiateReceiver);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (DEBUG_BROADCAST) Slog.i(TAG,
|
if (DEBUG_BROADCAST) Slog.i(TAG,
|
||||||
"Finishing failed broadcast to " + data.intent.getComponent());
|
"Finishing failed broadcast to " + data.intent.getComponent());
|
||||||
@@ -3258,13 +3251,12 @@ public final class ActivityThread {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (DEBUG_BACKUP) Slog.v(TAG, "Initializing agent class " + classname);
|
if (DEBUG_BACKUP) Slog.v(TAG, "Initializing agent class " + classname);
|
||||||
ContextImpl context = ContextImpl.createAppContext(this, packageInfo);
|
|
||||||
|
|
||||||
java.lang.ClassLoader cl = packageInfo.getClassLoader();
|
java.lang.ClassLoader cl = packageInfo.getClassLoader();
|
||||||
agent = instantiate(cl, classname, context,
|
agent = (BackupAgent) cl.loadClass(classname).newInstance();
|
||||||
Application::instantiateBackupAgent);
|
|
||||||
|
|
||||||
// set up the agent's context
|
// set up the agent's context
|
||||||
|
ContextImpl context = ContextImpl.createAppContext(this, packageInfo);
|
||||||
context.setOuterContext(agent);
|
context.setOuterContext(agent);
|
||||||
agent.attach(context);
|
agent.attach(context);
|
||||||
|
|
||||||
@@ -3324,12 +3316,9 @@ public final class ActivityThread {
|
|||||||
LoadedApk packageInfo = getPackageInfoNoCheck(
|
LoadedApk packageInfo = getPackageInfoNoCheck(
|
||||||
data.info.applicationInfo, data.compatInfo);
|
data.info.applicationInfo, data.compatInfo);
|
||||||
Service service = null;
|
Service service = null;
|
||||||
Application app = null;
|
|
||||||
try {
|
try {
|
||||||
app = packageInfo.makeApplication(false, mInstrumentation);
|
|
||||||
java.lang.ClassLoader cl = packageInfo.getClassLoader();
|
java.lang.ClassLoader cl = packageInfo.getClassLoader();
|
||||||
service = instantiate(cl, data.info.name, data.intent, app,
|
service = (Service) cl.loadClass(data.info.name).newInstance();
|
||||||
Application::instantiateService);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!mInstrumentation.onException(service, e)) {
|
if (!mInstrumentation.onException(service, e)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
@@ -3344,6 +3333,7 @@ public final class ActivityThread {
|
|||||||
ContextImpl context = ContextImpl.createAppContext(this, packageInfo);
|
ContextImpl context = ContextImpl.createAppContext(this, packageInfo);
|
||||||
context.setOuterContext(service);
|
context.setOuterContext(service);
|
||||||
|
|
||||||
|
Application app = packageInfo.makeApplication(false, mInstrumentation);
|
||||||
service.attach(context, this, data.info.name, data.token, app,
|
service.attach(context, this, data.info.name, data.token, app,
|
||||||
ActivityManager.getService());
|
ActivityManager.getService());
|
||||||
service.onCreate();
|
service.onCreate();
|
||||||
@@ -5682,8 +5672,8 @@ public final class ActivityThread {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final ClassLoader cl = instrContext.getClassLoader();
|
final ClassLoader cl = instrContext.getClassLoader();
|
||||||
mInstrumentation = instantiate(cl, data.instrumentationName.getClassName(),
|
mInstrumentation = (Instrumentation)
|
||||||
instrContext, Application::instantiateInstrumentation);
|
cl.loadClass(data.instrumentationName.getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Unable to instantiate instrumentation "
|
"Unable to instantiate instrumentation "
|
||||||
@@ -6234,8 +6224,8 @@ public final class ActivityThread {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final java.lang.ClassLoader cl = c.getClassLoader();
|
final java.lang.ClassLoader cl = c.getClassLoader();
|
||||||
localProvider = instantiate(cl, info.name, context,
|
localProvider = (ContentProvider)cl.
|
||||||
Application::instantiateProvider);
|
loadClass(info.name).newInstance();
|
||||||
provider = localProvider.getIContentProvider();
|
provider = localProvider.getIContentProvider();
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
Slog.e(TAG, "Failed to instantiate class " +
|
Slog.e(TAG, "Failed to instantiate class " +
|
||||||
@@ -6434,49 +6424,6 @@ public final class ActivityThread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T instantiate(ClassLoader cl, String className, Context c,
|
|
||||||
Instantiator<T> instantiator)
|
|
||||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
|
||||||
Application app = getApp(c);
|
|
||||||
if (app != null) {
|
|
||||||
T a = instantiator.instantiate(app, cl, className);
|
|
||||||
if (a != null) return a;
|
|
||||||
}
|
|
||||||
return (T) cl.loadClass(className).newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T instantiate(ClassLoader cl, String className, Intent intent, Context c,
|
|
||||||
IntentInstantiator<T> instantiator)
|
|
||||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
|
||||||
Application app = getApp(c);
|
|
||||||
if (app != null) {
|
|
||||||
T a = instantiator.instantiate(app, cl, className, intent);
|
|
||||||
if (a != null) return a;
|
|
||||||
}
|
|
||||||
return (T) cl.loadClass(className).newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Application getApp(Context c) {
|
|
||||||
// We need this shortcut to avoid actually calling getApplicationContext() on an Application
|
|
||||||
// because the Application may not return itself for getApplicationContext() because the
|
|
||||||
// API doesn't enforce it.
|
|
||||||
if (c instanceof Application) return (Application) c;
|
|
||||||
if (c.getApplicationContext() instanceof Application) {
|
|
||||||
return (Application) c.getApplicationContext();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private interface Instantiator<T> {
|
|
||||||
T instantiate(Application app, ClassLoader cl, String className)
|
|
||||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException;
|
|
||||||
}
|
|
||||||
|
|
||||||
private interface IntentInstantiator<T> {
|
|
||||||
T instantiate(Application app, ClassLoader cl, String className, Intent intent)
|
|
||||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class EventLoggingReporter implements EventLogger.Reporter {
|
private static class EventLoggingReporter implements EventLogger.Reporter {
|
||||||
@Override
|
@Override
|
||||||
public void report (int code, Object... list) {
|
public void report (int code, Object... list) {
|
||||||
|
|||||||
@@ -16,20 +16,17 @@
|
|||||||
|
|
||||||
package android.app;
|
package android.app;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import android.annotation.CallSuper;
|
import android.annotation.CallSuper;
|
||||||
import android.app.backup.BackupAgent;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.ComponentCallbacks;
|
import android.content.ComponentCallbacks;
|
||||||
import android.content.ComponentCallbacks2;
|
import android.content.ComponentCallbacks2;
|
||||||
import android.content.ContentProvider;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for maintaining global application state. You can provide your own
|
* Base class for maintaining global application state. You can provide your own
|
||||||
* implementation by creating a subclass and specifying the fully-qualified name
|
* implementation by creating a subclass and specifying the fully-qualified name
|
||||||
@@ -292,73 +289,4 @@ public class Application extends ContextWrapper implements ComponentCallbacks2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows application to override the creation of activities. This can be used to
|
|
||||||
* perform things such as dependency injection or class loader changes to these
|
|
||||||
* classes. Return null to use the default creation flow.
|
|
||||||
* @param cl The default classloader to use for instantiation.
|
|
||||||
* @param className The class to be instantiated.
|
|
||||||
* @param intent Intent creating the class.
|
|
||||||
*/
|
|
||||||
public Activity instantiateActivity(ClassLoader cl, String className, Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows application to override the creation of receivers. This can be used to
|
|
||||||
* perform things such as dependency injection or class loader changes to these
|
|
||||||
* classes. Return null to use the default creation flow.
|
|
||||||
* @param cl The default classloader to use for instantiation.
|
|
||||||
* @param className The class to be instantiated.
|
|
||||||
* @param intent Intent creating the class.
|
|
||||||
*/
|
|
||||||
public BroadcastReceiver instantiateReceiver(ClassLoader cl, String className, Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows application to override the creation of services. This can be used to
|
|
||||||
* perform things such as dependency injection or class loader changes to these
|
|
||||||
* classes. Return null to use the default creation flow.
|
|
||||||
* @param cl The default classloader to use for instantiation.
|
|
||||||
* @param className The class to be instantiated.
|
|
||||||
* @param intent Intent creating the class.
|
|
||||||
*/
|
|
||||||
public Service instantiateService(ClassLoader cl, String className, Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows application to override the creation of providers. This can be used to
|
|
||||||
* perform things such as dependency injection or class loader changes to these
|
|
||||||
* classes. Return null to use the default creation flow.
|
|
||||||
* @param cl The default classloader to use for instantiation.
|
|
||||||
* @param className The class to be instantiated.
|
|
||||||
*/
|
|
||||||
public ContentProvider instantiateProvider(ClassLoader cl, String className) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows application to override the creation of backup agents. This can be used to
|
|
||||||
* perform things such as dependency injection or class loader changes to these
|
|
||||||
* classes. Return null to use the default creation flow.
|
|
||||||
* @param cl The default classloader to use for instantiation.
|
|
||||||
* @param className The class to be instantiated.
|
|
||||||
*/
|
|
||||||
public BackupAgent instantiateBackupAgent(ClassLoader cl, String className) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows application to override the creation of instrumentation. This can be used to
|
|
||||||
* perform things such as dependency injection or class loader changes to these
|
|
||||||
* classes. Return null to use the default creation flow.
|
|
||||||
* @param cl The default classloader to use for instantiation.
|
|
||||||
* @param className The class to be instantiated.
|
|
||||||
*/
|
|
||||||
public Instrumentation instantiateInstrumentation(ClassLoader cl, String className) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
||||||
* except in compliance with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
|
||||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the specific language governing
|
|
||||||
* permissions and limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.systemui.plugins;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A PluginActivity is an activity that replaces another full activity (e.g. RecentsActivity)
|
|
||||||
* at runtime within the sysui process.
|
|
||||||
*/
|
|
||||||
@ProvidesInterface(version = PluginActivity.VERSION)
|
|
||||||
public abstract class PluginActivity extends Activity implements Plugin {
|
|
||||||
|
|
||||||
public static final int VERSION = 1;
|
|
||||||
|
|
||||||
public static final String ACTION_RECENTS = "com.android.systemui.action.PLUGIN_RECENTS";
|
|
||||||
|
|
||||||
private Context mSysuiContext;
|
|
||||||
private boolean mSettingActionBar;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void onCreate(Context sysuiContext, Context pluginContext) {
|
|
||||||
mSysuiContext = sysuiContext;
|
|
||||||
super.attachBaseContext(pluginContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
Theme theme = getClass().getDeclaredAnnotation(Theme.class);
|
|
||||||
if (theme != null && theme.value() != 0) {
|
|
||||||
setTheme(theme.value());
|
|
||||||
}
|
|
||||||
mSettingActionBar = true;
|
|
||||||
getActionBar();
|
|
||||||
mSettingActionBar = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Resources getResources() {
|
|
||||||
return mSettingActionBar ? mSysuiContext.getResources() : super.getResources();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void attachBaseContext(Context newBase) {
|
|
||||||
mSysuiContext = newBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Context getSysuiContext() {
|
|
||||||
return mSysuiContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Context getPluginContext() {
|
|
||||||
return getBaseContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Since PluginActivities are declared as services instead of activities (since they
|
|
||||||
* are plugins), they can't have a theme attached to them. Instead a PluginActivity
|
|
||||||
* can annotate itself with @Theme to specify the resource of the style it wants
|
|
||||||
* to be themed with.
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface Theme {
|
|
||||||
int value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,11 +21,6 @@ public class PluginDependency {
|
|||||||
public static final int VERSION = 1;
|
public static final int VERSION = 1;
|
||||||
static DependencyProvider sProvider;
|
static DependencyProvider sProvider;
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows a plugin to get a hold of static dependencies if they have declared dependence
|
|
||||||
* on their interface. For one-shot plugins this will only work during onCreate and will
|
|
||||||
* not work afterwards.
|
|
||||||
*/
|
|
||||||
public static <T> T get(Plugin p, Class<T> cls) {
|
public static <T> T get(Plugin p, Class<T> cls) {
|
||||||
return sProvider.get(p, cls);
|
return sProvider.get(p, cls);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import com.android.systemui.fragments.FragmentService;
|
|||||||
import com.android.systemui.keyguard.ScreenLifecycle;
|
import com.android.systemui.keyguard.ScreenLifecycle;
|
||||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||||
import com.android.systemui.plugins.ActivityStarter;
|
import com.android.systemui.plugins.ActivityStarter;
|
||||||
import com.android.systemui.plugins.PluginActivityManager;
|
|
||||||
import com.android.systemui.plugins.PluginDependencyProvider;
|
import com.android.systemui.plugins.PluginDependencyProvider;
|
||||||
import com.android.systemui.plugins.PluginManager;
|
import com.android.systemui.plugins.PluginManager;
|
||||||
import com.android.systemui.plugins.PluginManagerImpl;
|
import com.android.systemui.plugins.PluginManagerImpl;
|
||||||
@@ -295,8 +294,6 @@ public class Dependency extends SystemUI {
|
|||||||
|
|
||||||
mProviders.put(UiOffloadThread.class, UiOffloadThread::new);
|
mProviders.put(UiOffloadThread.class, UiOffloadThread::new);
|
||||||
|
|
||||||
mProviders.put(PluginActivityManager.class,
|
|
||||||
() -> new PluginActivityManager(mContext, getDependency(PluginManager.class)));
|
|
||||||
|
|
||||||
mProviders.put(PowerUI.WarningsUI.class, () -> new PowerNotificationWarnings(mContext));
|
mProviders.put(PowerUI.WarningsUI.class, () -> new PowerNotificationWarnings(mContext));
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.systemui;
|
package com.android.systemui;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ActivityThread;
|
import android.app.ActivityThread;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -41,7 +40,6 @@ import com.android.systemui.pip.PipUI;
|
|||||||
import com.android.systemui.plugins.GlobalActions;
|
import com.android.systemui.plugins.GlobalActions;
|
||||||
import com.android.systemui.plugins.OverlayPlugin;
|
import com.android.systemui.plugins.OverlayPlugin;
|
||||||
import com.android.systemui.plugins.Plugin;
|
import com.android.systemui.plugins.Plugin;
|
||||||
import com.android.systemui.plugins.PluginActivityManager;
|
|
||||||
import com.android.systemui.plugins.PluginListener;
|
import com.android.systemui.plugins.PluginListener;
|
||||||
import com.android.systemui.plugins.PluginManager;
|
import com.android.systemui.plugins.PluginManager;
|
||||||
import com.android.systemui.power.PowerUI;
|
import com.android.systemui.power.PowerUI;
|
||||||
@@ -281,10 +279,4 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
|
|||||||
public SystemUI[] getServices() {
|
public SystemUI[] getServices() {
|
||||||
return mServices;
|
return mServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Activity instantiateActivity(ClassLoader cl, String className, Intent intent) {
|
|
||||||
if (!mServicesStarted) return null;
|
|
||||||
return Dependency.get(PluginActivityManager.class).instantiate(cl, className, intent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
||||||
* except in compliance with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
|
||||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the specific language governing
|
|
||||||
* permissions and limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.systemui.plugins;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.ArrayMap;
|
|
||||||
|
|
||||||
public class PluginActivityManager {
|
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
private final PluginManager mPluginManager;
|
|
||||||
private final ArrayMap<String, String> mActionLookup = new ArrayMap<>();
|
|
||||||
|
|
||||||
public PluginActivityManager(Context context, PluginManager pluginManager) {
|
|
||||||
mContext = context;
|
|
||||||
mPluginManager = pluginManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addActivityPlugin(String className, String action) {
|
|
||||||
mActionLookup.put(className, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Activity instantiate(ClassLoader cl, String className, Intent intent) {
|
|
||||||
String action = mActionLookup.get(className);
|
|
||||||
if (TextUtils.isEmpty(action)) return null;
|
|
||||||
return mPluginManager.getOneShotPlugin(action, PluginActivity.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -42,6 +42,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
|||||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||||
import com.android.systemui.Dependency;
|
import com.android.systemui.Dependency;
|
||||||
import com.android.systemui.plugins.PluginInstanceManager.PluginContextWrapper;
|
import com.android.systemui.plugins.PluginInstanceManager.PluginContextWrapper;
|
||||||
|
import com.android.systemui.plugins.PluginInstanceManager.PluginInfo;
|
||||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||||
|
|
||||||
import dalvik.system.PathClassLoader;
|
import dalvik.system.PathClassLoader;
|
||||||
@@ -119,21 +120,14 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
|||||||
}
|
}
|
||||||
PluginInstanceManager<T> p = mFactory.createPluginInstanceManager(mContext, action, null,
|
PluginInstanceManager<T> p = mFactory.createPluginInstanceManager(mContext, action, null,
|
||||||
false, mLooper, cls, this);
|
false, mLooper, cls, this);
|
||||||
PluginListener<Plugin> listener = new PluginListener<Plugin>() {
|
|
||||||
@Override
|
|
||||||
public void onPluginConnected(Plugin plugin, Context pluginContext) { }
|
|
||||||
};
|
|
||||||
mPluginMap.put(listener, p);
|
|
||||||
mPluginPrefs.addAction(action);
|
mPluginPrefs.addAction(action);
|
||||||
PluginInstanceManager.PluginInfo<T> info = p.getPlugin();
|
PluginInfo<T> info = p.getPlugin();
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
mOneShotPackages.add(info.mPackage);
|
mOneShotPackages.add(info.mPackage);
|
||||||
mHasOneShot = true;
|
mHasOneShot = true;
|
||||||
startListening();
|
startListening();
|
||||||
mPluginMap.remove(listener);
|
|
||||||
return info.mPlugin;
|
return info.mPlugin;
|
||||||
}
|
}
|
||||||
mPluginMap.remove(listener);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,14 +43,11 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.systemui.Dependency;
|
|
||||||
import com.android.systemui.EventLogConstants;
|
import com.android.systemui.EventLogConstants;
|
||||||
import com.android.systemui.EventLogTags;
|
import com.android.systemui.EventLogTags;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.RecentsComponent;
|
import com.android.systemui.RecentsComponent;
|
||||||
import com.android.systemui.SystemUI;
|
import com.android.systemui.SystemUI;
|
||||||
import com.android.systemui.plugins.PluginActivity;
|
|
||||||
import com.android.systemui.plugins.PluginActivityManager;
|
|
||||||
import com.android.systemui.recents.events.EventBus;
|
import com.android.systemui.recents.events.EventBus;
|
||||||
import com.android.systemui.recents.events.activity.ConfigurationChangedEvent;
|
import com.android.systemui.recents.events.activity.ConfigurationChangedEvent;
|
||||||
import com.android.systemui.recents.events.activity.DockedTopTaskEvent;
|
import com.android.systemui.recents.events.activity.DockedTopTaskEvent;
|
||||||
@@ -239,8 +236,6 @@ public class Recents extends SystemUI
|
|||||||
registerWithSystemUser();
|
registerWithSystemUser();
|
||||||
}
|
}
|
||||||
putComponent(Recents.class, this);
|
putComponent(Recents.class, this);
|
||||||
Dependency.get(PluginActivityManager.class).addActivityPlugin(RecentsImpl.RECENTS_ACTIVITY,
|
|
||||||
PluginActivity.ACTION_RECENTS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.support.test.annotation.UiThreadTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
@@ -34,10 +36,11 @@ import android.testing.TestableLooper.RunWithLooper;
|
|||||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||||
import com.android.systemui.Dependency;
|
import com.android.systemui.Dependency;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.plugins.PluginInstanceManager.PluginInfo;
|
|
||||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||||
|
import com.android.systemui.plugins.PluginInstanceManager.PluginInfo;
|
||||||
import com.android.systemui.plugins.PluginManagerImpl.PluginInstanceManagerFactory;
|
import com.android.systemui.plugins.PluginManagerImpl.PluginInstanceManagerFactory;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.utils.leaks;
|
package com.android.systemui.utils.leaks;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.testing.LeakCheck;
|
import android.testing.LeakCheck;
|
||||||
|
|
||||||
import com.android.systemui.plugins.Plugin;
|
import com.android.systemui.plugins.Plugin;
|
||||||
|
|||||||
Reference in New Issue
Block a user