Home | History | Annotate | Download | only in activity
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.googlecode.android_scripting.activity;
     18 
     19 import android.app.Activity;
     20 import android.content.Intent;
     21 import android.os.Bundle;
     22 import android.os.SystemProperties;
     23 
     24 import android.util.Log;
     25 
     26 import com.googlecode.android_scripting.Constants;
     27 
     28 public class ScriptingLayerServiceLauncher extends Activity {
     29 
     30     private static final int DEBUGGABLE_BUILD = 1;
     31 
     32     private static final String LOG_TAG = "sl4a";
     33   @Override
     34   protected void onCreate(Bundle savedInstanceState) {
     35     super.onCreate(savedInstanceState);
     36     // Forward the intent that launched us to start the service.
     37 
     38     if(SystemProperties.getInt("ro.debuggable", 0) == DEBUGGABLE_BUILD) {
     39         Intent intent = getIntent();
     40         intent.setComponent(Constants.SL4A_SERVICE_COMPONENT_NAME);
     41         startService(intent);
     42         finish();
     43     }
     44     else {
     45         Log.e(LOG_TAG, "ERROR: Cannot to start SL4A on non-debuggable build!");
     46     }
     47   }
     48 }
     49