Change settings only for emulator
am: c91a33d3df
Change-Id: Ie630b302fff2235977d512ca77e49abc3fd54895
This commit is contained in:
@@ -25,6 +25,7 @@ import android.location.LocationManager;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,32 +38,37 @@ public class DefaultActivity extends Activity {
|
|||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
// Add a persistent setting to allow other apps to know the device has been provisioned.
|
// Edit Settings only for Emulator
|
||||||
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
|
if (Build.IS_EMULATOR) {
|
||||||
|
// Add a persistent setting to allow other apps to know the device has been provisioned.
|
||||||
|
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
|
||||||
|
|
||||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
|
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
|
||||||
|
|
||||||
// Disables a dialog shown on adb install execution.
|
// Disables a dialog shown on adb install execution.
|
||||||
Settings.Global.putInt(getContentResolver(), Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 0);
|
Settings.Global.putInt(getContentResolver(), Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 0);
|
||||||
|
|
||||||
// Enable the GPS.
|
// Enable the GPS.
|
||||||
// Not needed since this SDK will contain the Settings app.
|
// Not needed since this SDK will contain the Settings app.
|
||||||
Settings.Secure.putString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
|
Settings.Secure.putString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
|
||||||
LocationManager.GPS_PROVIDER + "," + LocationManager.NETWORK_PROVIDER);
|
LocationManager.GPS_PROVIDER + "," + LocationManager.NETWORK_PROVIDER);
|
||||||
|
|
||||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.LOCATION_MODE,
|
Settings.Secure.putInt(getContentResolver(), Settings.Secure.LOCATION_MODE,
|
||||||
Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
||||||
|
|
||||||
// enable install from non market
|
// enable install from non market
|
||||||
Settings.Global.putInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS, 1);
|
Settings.Global.putInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS, 1);
|
||||||
|
|
||||||
// provision the backup manager.
|
Settings.Secure.putInt(getContentResolver(),Settings.Secure.ADB_ENABLED, 1);
|
||||||
IBackupManager bm = IBackupManager.Stub.asInterface(
|
|
||||||
ServiceManager.getService(Context.BACKUP_SERVICE));
|
// provision the backup manager.
|
||||||
if (bm != null) {
|
IBackupManager bm = IBackupManager.Stub.asInterface(
|
||||||
try {
|
ServiceManager.getService(Context.BACKUP_SERVICE));
|
||||||
bm.setBackupProvisioned(true);
|
if (bm != null) {
|
||||||
} catch (RemoteException e) {
|
try {
|
||||||
|
bm.setBackupProvisioned(true);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +76,6 @@ public class DefaultActivity extends Activity {
|
|||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
ComponentName name = new ComponentName(this, DefaultActivity.class);
|
ComponentName name = new ComponentName(this, DefaultActivity.class);
|
||||||
pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||||
Settings.Secure.putInt(getContentResolver(),Settings.Secure.ADB_ENABLED, 1);
|
|
||||||
|
|
||||||
// terminate the activity.
|
// terminate the activity.
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
Reference in New Issue
Block a user