1 /* 2 * Copyright (C) 2008 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.android.sdksetup; 18 19 import android.app.Activity; 20 import android.app.backup.IBackupManager; 21 import android.content.ComponentName; 22 import android.content.Context; 23 import android.content.pm.PackageManager; 24 import android.location.LocationManager; 25 import android.os.Bundle; 26 import android.os.RemoteException; 27 import android.os.ServiceManager; 28 import android.os.Build; 29 import android.provider.Settings; 30 31 /** 32 * Entry point for SDK SetupWizard. 33 * 34 */ 35 public class DefaultActivity extends Activity { 36 37 @Override onCreate(Bundle icicle)38 protected void onCreate(Bundle icicle) { 39 super.onCreate(icicle); 40 41 // Edit Settings only for Emulator 42 if (Build.IS_EMULATOR) { 43 // Add a persistent setting to allow other apps to know the device has been provisioned. 44 Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1); 45 46 Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1); 47 48 // Disables a dialog shown on adb install execution. 49 Settings.Global.putInt(getContentResolver(), Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 0); 50 51 // Enable the GPS. 52 // Not needed since this SDK will contain the Settings app. 53 Settings.Secure.putString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, 54 LocationManager.GPS_PROVIDER); 55 56 // enable install from non market 57 Settings.Global.putInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS, 1); 58 59 Settings.Secure.putInt(getContentResolver(),Settings.Secure.ADB_ENABLED, 1); 60 61 // provision the backup manager. 62 IBackupManager bm = IBackupManager.Stub.asInterface( 63 ServiceManager.getService(Context.BACKUP_SERVICE)); 64 if (bm != null) { 65 try { 66 bm.setBackupProvisioned(true); 67 } catch (RemoteException e) { 68 } 69 } 70 } 71 72 // remove this activity from the package manager. 73 PackageManager pm = getPackageManager(); 74 ComponentName name = new ComponentName(this, DefaultActivity.class); 75 pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); 76 77 // terminate the activity. 78 finish(); 79 } 80 } 81 82