Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
      5  * except in compliance with the License. You may obtain a copy of the License at
      6  *
      7  *      http://www.apache.org/licenses/LICENSE-2.0
      8  *
      9  * Unless required by applicable law or agreed to in writing, software distributed under the
     10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     11  * KIND, either express or implied. See the License for the specific language governing
     12  * permissions and limitations under the License.
     13  */
     14 
     15 package android.app.componentfactory.cts;
     16 
     17 import android.app.Activity;
     18 import android.app.AppComponentFactory;
     19 import android.app.Application;
     20 import android.app.Service;
     21 import android.content.BroadcastReceiver;
     22 import android.content.ContentProvider;
     23 import android.content.Intent;
     24 
     25 public class MyFactory extends AppComponentFactory {
     26 
     27     @Override
     28     public Application instantiateApplication(ClassLoader cl, String className)
     29             throws InstantiationException, IllegalAccessException, ClassNotFoundException {
     30         if (className.contains(".inject")) {
     31             className = className.replace(".inject", "");
     32         }
     33         return super.instantiateApplication(cl, className);
     34     }
     35 
     36     @Override
     37     public Activity instantiateActivity(ClassLoader cl, String className, Intent intent)
     38             throws InstantiationException, IllegalAccessException, ClassNotFoundException {
     39         if (className.contains(".inject")) {
     40             className = className.replace(".inject", "");
     41         }
     42         return super.instantiateActivity(cl, className, intent);
     43     }
     44 
     45     @Override
     46     public BroadcastReceiver instantiateReceiver(ClassLoader cl, String className, Intent intent)
     47             throws InstantiationException, IllegalAccessException, ClassNotFoundException {
     48         if (className.contains(".inject")) {
     49             className = className.replace(".inject", "");
     50         }
     51         return super.instantiateReceiver(cl, className, intent);
     52     }
     53 
     54     @Override
     55     public ContentProvider instantiateProvider(ClassLoader cl, String className)
     56             throws InstantiationException, IllegalAccessException, ClassNotFoundException {
     57         if (className.contains(".inject")) {
     58             className = className.replace(".inject", "");
     59         }
     60         return super.instantiateProvider(cl, className);
     61     }
     62 
     63     @Override
     64     public Service instantiateService(ClassLoader cl, String className, Intent intent)
     65             throws InstantiationException, IllegalAccessException, ClassNotFoundException {
     66         if (className.contains(".inject")) {
     67             className = className.replace(".inject", "");
     68         }
     69         return super.instantiateService(cl, className, intent);
     70     }
     71 }
     72