change remaining frameworks/base Gservices to Secure settings

Change-Id: I61bdb05a2526523700c2833154d5a4133881ef10
This commit is contained in:
Doug Zongker
2010-01-07 13:51:16 -08:00
parent 43866e0c48
commit edc5189c33
12 changed files with 176 additions and 227 deletions

View File

@@ -339,19 +339,9 @@ public final class AndroidHttpClient implements HttpClient {
* Shorter data will not be compressed.
*/
public static long getMinGzipSize(ContentResolver resolver) {
String sMinGzipBytes = Settings.Gservices.getString(resolver,
Settings.Gservices.SYNC_MIN_GZIP_BYTES);
if (!TextUtils.isEmpty(sMinGzipBytes)) {
try {
return Long.parseLong(sMinGzipBytes);
} catch (NumberFormatException nfe) {
Log.w(TAG, "Unable to parse " +
Settings.Gservices.SYNC_MIN_GZIP_BYTES + " " +
sMinGzipBytes, nfe);
}
}
return DEFAULT_SYNC_MIN_GZIP_BYTES;
return Settings.Secure.getLong(resolver,
Settings.Secure.SYNC_MIN_GZIP_BYTES,
DEFAULT_SYNC_MIN_GZIP_BYTES);
}
/* cURL logging support. */

View File

@@ -859,8 +859,8 @@ class SyncManager implements OnAccountsUpdateListener {
}
// Cap the delay
long maxSyncRetryTimeInSeconds = Settings.Gservices.getLong(mContext.getContentResolver(),
Settings.Gservices.SYNC_MAX_RETRY_DELAY_IN_SECONDS,
long maxSyncRetryTimeInSeconds = Settings.Secure.getLong(mContext.getContentResolver(),
Settings.Secure.SYNC_MAX_RETRY_DELAY_IN_SECONDS,
DEFAULT_MAX_SYNC_RETRY_TIME_IN_SECONDS);
if (newDelayInMs > maxSyncRetryTimeInSeconds * 1000) {
newDelayInMs = maxSyncRetryTimeInSeconds * 1000;

View File

@@ -2680,6 +2680,139 @@ public final class Settings {
*/
public static final String WIFI_IDLE_MS = "wifi_idle_ms";
/**
* The interval in milliseconds at which to check packet counts on the
* mobile data interface when screen is on, to detect possible data
* connection problems.
* @hide
*/
public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
"pdp_watchdog_poll_interval_ms";
/**
* The interval in milliseconds at which to check packet counts on the
* mobile data interface when screen is off, to detect possible data
* connection problems.
* @hide
*/
public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
"pdp_watchdog_long_poll_interval_ms";
/**
* The interval in milliseconds at which to check packet counts on the
* mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
* outgoing packets has been reached without incoming packets.
* @hide
*/
public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
"pdp_watchdog_error_poll_interval_ms";
/**
* The number of outgoing packets sent without seeing an incoming packet
* that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
* device is logged to the event log
* @hide
*/
public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
"pdp_watchdog_trigger_packet_count";
/**
* The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
* after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
* attempting data connection recovery.
* @hide
*/
public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
"pdp_watchdog_error_poll_count";
/**
* The number of failed PDP reset attempts before moving to something more
* drastic: re-registering to the network.
* @hide
*/
public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
"pdp_watchdog_max_pdp_reset_fail_count";
/**
* Address to ping as a last sanity check before attempting any recovery.
* Unset or set to "0.0.0.0" to skip this check.
* @hide
*/
public static final String PDP_WATCHDOG_PING_ADDRESS = "pdp_watchdog_ping_address";
/**
* The "-w deadline" parameter for the ping, ie, the max time in
* seconds to spend pinging.
* @hide
*/
public static final String PDP_WATCHDOG_PING_DEADLINE = "pdp_watchdog_ping_deadline";
/**
* The interval in milliseconds at which to check gprs registration
* after the first registration mismatch of gprs and voice service,
* to detect possible data network registration problems.
*
* @hide
*/
public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
"gprs_register_check_period_ms";
/**
* The length of time in milli-seconds that automatic small adjustments to
* SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded.
* @hide
*/
public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing";
/**
* If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment
* to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been
* exceeded.
* @hide
*/
public static final String NITZ_UPDATE_DIFF = "nitz_update_diff";
/**
* The maximum reconnect delay for short network outages or when the network is suspended
* due to phone use.
* @hide
*/
public static final String SYNC_MAX_RETRY_DELAY_IN_SECONDS =
"sync_max_retry_delay_in_seconds";
/**
* The interval in milliseconds at which to check the number of SMS sent
* out without asking for use permit, to limit the un-authorized SMS
* usage.
* @hide
*/
public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
"sms_outgoing_check_interval_ms";
/**
* The number of outgoing SMS sent without asking for user permit
* (of {@link #SMS_OUTGOING_CHECK_INTERVAL_MS}
* @hide
*/
public static final String SMS_OUTGOING_CHECK_MAX_COUNT =
"sms_outgoing_check_max_count";
/**
* Enable use of ssl session caching.
* 'db' - save each session in a (per process) database
* 'file' - save each session in a (per process) file
* not set or any other value - normal java in-memory caching
* @hide
*/
public static final String SSL_SESSION_CACHE = "ssl_session_cache";
/**
* How many bytes long a message has to be, in order to be gzipped.
* @hide
*/
public static final String SYNC_MIN_GZIP_BYTES =
"sync_min_gzip_bytes";
/**
* @hide
*/
@@ -3254,20 +3387,6 @@ public final class Settings {
*/
public static final String GSYNC_USE_RMQ2_ROUTING_INFO = "gsync_use_rmq2_routing_info";
/**
* Enable use of ssl session caching.
* 'db' - save each session in a (per process) database
* 'file' - save each session in a (per process) file
* not set or any other value - normal java in-memory caching
*/
public static final String SSL_SESSION_CACHE = "ssl_session_cache";
/**
* How many bytes long a message has to be, in order to be gzipped.
*/
public static final String SYNC_MIN_GZIP_BYTES =
"sync_min_gzip_bytes";
/**
* The hash value of the current provisioning settings
*/
@@ -3539,96 +3658,6 @@ public final class Settings {
public static final String GOOGLE_SERVICES_PREFIX
= "google_services:";
/**
* The maximum reconnect delay for short network outages or when the network is suspended
* due to phone use.
*/
public static final String SYNC_MAX_RETRY_DELAY_IN_SECONDS =
"sync_max_retry_delay_in_seconds";
/**
* The interval in milliseconds at which to check the number of SMS sent
* out without asking for use permit, to limit the un-authorized SMS
* usage.
*/
public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
"sms_outgoing_check_interval_ms";
/**
* The number of outgoing SMS sent without asking for user permit
* (of {@link #SMS_OUTGOING_CHECK_INTERVAL_MS}
*/
public static final String SMS_OUTGOING_CEHCK_MAX_COUNT =
"sms_outgoing_check_max_count";
/**
* The interval in milliseconds at which to check packet counts on the
* mobile data interface when screen is on, to detect possible data
* connection problems.
*/
public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
"pdp_watchdog_poll_interval_ms";
/**
* The interval in milliseconds at which to check packet counts on the
* mobile data interface when screen is off, to detect possible data
* connection problems.
*/
public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
"pdp_watchdog_long_poll_interval_ms";
/**
* The interval in milliseconds at which to check packet counts on the
* mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
* outgoing packets has been reached without incoming packets.
*/
public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
"pdp_watchdog_error_poll_interval_ms";
/**
* The number of outgoing packets sent without seeing an incoming packet
* that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
* device is logged to the event log
*/
public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
"pdp_watchdog_trigger_packet_count";
/**
* The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
* after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
* attempting data connection recovery.
*/
public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
"pdp_watchdog_error_poll_count";
/**
* The number of failed PDP reset attempts before moving to something more
* drastic: re-registering to the network.
*/
public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
"pdp_watchdog_max_pdp_reset_fail_count";
/**
* Address to ping as a last sanity check before attempting any recovery.
* Unset or set to "0.0.0.0" to skip this check.
*/
public static final String PDP_WATCHDOG_PING_ADDRESS = "pdp_watchdog_ping_address";
/**
* The "-w deadline" parameter for the ping, ie, the max time in
* seconds to spend pinging.
*/
public static final String PDP_WATCHDOG_PING_DEADLINE = "pdp_watchdog_ping_deadline";
/**
* The interval in milliseconds at which to check gprs registration
* after the first registration mismatch of gprs and voice service,
* to detect possible data network registration problems.
*
*/
public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
"gprs_register_check_period_ms";
/**
* List of test suites (local disk filename) for the automatic instrumentation test runner.
* The file format is similar to automated_suites.xml, see AutoTesterService.
@@ -3755,19 +3784,6 @@ public final class Settings {
*/
public static final String LAST_KMSG_KB = "last_kmsg_kb";
/**
* The length of time in milli-seconds that automatic small adjustments to
* SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded.
*/
public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing";
/**
* If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment
* to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been
* exceeded.
*/
public static final String NITZ_UPDATE_DIFF = "nitz_update_diff";
/**
* @deprecated
* @hide

View File

@@ -139,8 +139,6 @@ public class SettingsProvider extends ContentProvider {
} else if (table.equals("secure")) {
property = Settings.Secure.SYS_PROP_SETTING_VERSION;
backedUpDataChanged = true;
} else if (table.equals("gservices")) {
property = Settings.Gservices.SYS_PROP_SETTING_VERSION;
}
if (property != null) {

View File

@@ -224,11 +224,11 @@ public abstract class SMSDispatcher extends Handler {
createWakelock();
int check_period = Settings.Gservices.getInt(mResolver,
Settings.Gservices.SMS_OUTGOING_CHECK_INTERVAL_MS,
int check_period = Settings.Secure.getInt(mResolver,
Settings.Secure.SMS_OUTGOING_CHECK_INTERVAL_MS,
DEFAULT_SMS_CHECK_PERIOD);
int max_count = Settings.Gservices.getInt(mResolver,
Settings.Gservices.SMS_OUTGOING_CEHCK_MAX_COUNT,
int max_count = Settings.Secure.getInt(mResolver,
Settings.Secure.SMS_OUTGOING_CHECK_MAX_COUNT,
DEFAULT_SMS_MAX_COUNT);
mCounter = new SmsCounter(max_count, check_period);

View File

@@ -1463,10 +1463,10 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
*/
long gained = c.getTimeInMillis() - System.currentTimeMillis();
long timeSinceLastUpdate = SystemClock.elapsedRealtime() - mSavedAtTime;
int nitzUpdateSpacing = Settings.Gservices.getInt(cr,
Settings.Gservices.NITZ_UPDATE_SPACING, mNitzUpdateSpacing);
int nitzUpdateDiff = Settings.Gservices.getInt(cr,
Settings.Gservices.NITZ_UPDATE_DIFF, mNitzUpdateDiff);
int nitzUpdateSpacing = Settings.Secure.getInt(cr,
Settings.Secure.NITZ_UPDATE_SPACING, mNitzUpdateSpacing);
int nitzUpdateDiff = Settings.Secure.getInt(cr,
Settings.Secure.NITZ_UPDATE_DIFF, mNitzUpdateDiff);
if ((mSavedAtTime == 0) || (timeSinceLastUpdate > nitzUpdateSpacing)
|| (Math.abs(gained) > nitzUpdateDiff)) {

View File

@@ -773,8 +773,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
private void doRecovery() {
if (state == State.CONNECTED) {
int maxPdpReset = Settings.Gservices.getInt(mResolver,
Settings.Gservices.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT,
int maxPdpReset = Settings.Secure.getInt(mResolver,
Settings.Secure.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT,
DEFAULT_MAX_PDP_RESET_FAIL);
if (mPdpResetCount < maxPdpReset) {
mPdpResetCount++;
@@ -875,8 +875,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
}
}
int watchdogTrigger = Settings.Gservices.getInt(mResolver,
Settings.Gservices.PDP_WATCHDOG_TRIGGER_PACKET_COUNT,
int watchdogTrigger = Settings.Secure.getInt(mResolver,
Settings.Secure.PDP_WATCHDOG_TRIGGER_PACKET_COUNT,
NUMBER_SENT_PACKETS_OF_HANG);
if (sentSinceLastRecv >= watchdogTrigger) {
@@ -886,8 +886,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
sentSinceLastRecv);
}
int noRecvPollLimit = Settings.Gservices.getInt(mResolver,
Settings.Gservices.PDP_WATCHDOG_ERROR_POLL_COUNT, NO_RECV_POLL_LIMIT);
int noRecvPollLimit = Settings.Secure.getInt(mResolver,
Settings.Secure.PDP_WATCHDOG_ERROR_POLL_COUNT, NO_RECV_POLL_LIMIT);
if (mNoRecvPollCount < noRecvPollLimit) {
// It's possible the PDP context went down and we weren't notified.
@@ -898,8 +898,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
mNoRecvPollCount++;
// Slow down the poll interval to let things happen
netStatPollPeriod = Settings.Gservices.getInt(mResolver,
Settings.Gservices.PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS,
netStatPollPeriod = Settings.Secure.getInt(mResolver,
Settings.Secure.PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS,
POLL_NETSTAT_SLOW_MILLIS);
} else {
if (DBG) log("Sent " + String.valueOf(sentSinceLastRecv) +
@@ -918,11 +918,11 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
} else {
mNoRecvPollCount = 0;
if (mIsScreenOn) {
netStatPollPeriod = Settings.Gservices.getInt(mResolver,
Settings.Gservices.PDP_WATCHDOG_POLL_INTERVAL_MS, POLL_NETSTAT_MILLIS);
netStatPollPeriod = Settings.Secure.getInt(mResolver,
Settings.Secure.PDP_WATCHDOG_POLL_INTERVAL_MS, POLL_NETSTAT_MILLIS);
} else {
netStatPollPeriod = Settings.Gservices.getInt(mResolver,
Settings.Gservices.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS,
netStatPollPeriod = Settings.Secure.getInt(mResolver,
Settings.Secure.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS,
POLL_NETSTAT_SCREEN_OFF_MILLIS);
}
}
@@ -936,10 +936,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
private void runPingTest () {
int status = -1;
try {
String address = Settings.Gservices.getString(mResolver,
Settings.Gservices.PDP_WATCHDOG_PING_ADDRESS);
int deadline = Settings.Gservices.getInt(mResolver,
Settings.Gservices.PDP_WATCHDOG_PING_DEADLINE, DEFAULT_PING_DEADLINE);
String address = Settings.Secure.getString(mResolver,
Settings.Secure.PDP_WATCHDOG_PING_ADDRESS);
int deadline = Settings.Secure.getInt(mResolver,
Settings.Secure.PDP_WATCHDOG_PING_DEADLINE, DEFAULT_PING_DEADLINE);
if (DBG) log("pinging " + address + " for " + deadline + "s");
if (address != null && !NULL_IP.equals(address)) {
Process p = Runtime.getRuntime()

View File

@@ -959,9 +959,9 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
if (!mStartedGprsRegCheck && !mReportedGprsNoReg) {
mStartedGprsRegCheck = true;
int check_period = Settings.Gservices.getInt(
int check_period = Settings.Secure.getInt(
phone.getContext().getContentResolver(),
Settings.Gservices.GPRS_REGISTER_CHECK_PERIOD_MS,
Settings.Secure.GPRS_REGISTER_CHECK_PERIOD_MS,
DEFAULT_GPRS_CHECK_PERIOD_MILLIS);
sendMessageDelayed(obtainMessage(EVENT_CHECK_REPORT_GPRS),
check_period);

View File

@@ -48,7 +48,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SMS"/>

View File

@@ -31,16 +31,16 @@ public class SettingsProviderTest extends AndroidTestCase {
@MediumTest
public void testNameValueCache() {
ContentResolver r = getContext().getContentResolver();
Settings.Gservices.putString(r, "test_service", "Value");
assertEquals("Value", Settings.Gservices.getString(r, "test_service"));
Settings.Secure.putString(r, "test_service", "Value");
assertEquals("Value", Settings.Secure.getString(r, "test_service"));
// Make sure the value can be overwritten.
Settings.Gservices.putString(r, "test_service", "New");
assertEquals("New", Settings.Gservices.getString(r, "test_service"));
Settings.Secure.putString(r, "test_service", "New");
assertEquals("New", Settings.Secure.getString(r, "test_service"));
// Also that delete works.
assertEquals(1, r.delete(Settings.Gservices.getUriFor("test_service"), null, null));
assertEquals(null, Settings.Gservices.getString(r, "test_service"));
assertEquals(1, r.delete(Settings.Secure.getUriFor("test_service"), null, null));
assertEquals(null, Settings.Secure.getString(r, "test_service"));
// Try all the same things in the System table
Settings.System.putString(r, "test_setting", "Value");
@@ -60,10 +60,10 @@ public class SettingsProviderTest extends AndroidTestCase {
assertEquals("content://settings/system/test_setting",
Settings.System.getUriFor("test_setting").toString());
assertEquals("content://settings/gservices/test_service",
Settings.Gservices.getUriFor("test_service").toString());
Settings.Secure.getUriFor("test_service").toString());
// These tables use the row name (not ID) as their content URI.
Uri tables[] = { Settings.System.CONTENT_URI, Settings.Gservices.CONTENT_URI };
Uri tables[] = { Settings.System.CONTENT_URI, Settings.Secure.CONTENT_URI };
for (Uri table : tables) {
ContentValues v = new ContentValues();
v.put(Settings.System.NAME, "test_key");
@@ -119,7 +119,7 @@ public class SettingsProviderTest extends AndroidTestCase {
}
assertEquals(null, Settings.System.getString(r, "test_key"));
assertEquals(null, Settings.Gservices.getString(r, "test_key"));
assertEquals(null, Settings.Secure.getString(r, "test_key"));
}
@MediumTest

View File

@@ -136,8 +136,8 @@ public class DatabaseSessionCache implements SSLClientSessionCache {
}
// public static boolean enabled(Context androidContext) {
// String sslCache = Settings.Gservices.getString(androidContext.getContentResolver(),
// Settings.Gservices.SSL_SESSION_CACHE);
// String sslCache = Settings.Secure.getString(androidContext.getContentResolver(),
// Settings.Secure.SSL_SESSION_CACHE);
//
// if (Log.isLoggable(TAG, Log.DEBUG)) {
// Log.d(TAG, "enabled " + sslCache + " " + androidContext.getPackageName());
@@ -309,4 +309,4 @@ public class DatabaseSessionCache implements SSLClientSessionCache {
}
}
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (C) 2009 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.framework.permission.tests;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.provider.Settings;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
/**
* Verify that accessing private-API protected Settings require specific permissions.
*/
public class SettingsPermissionsTests extends AndroidTestCase {
private ContentResolver mContentResolver;
@Override
protected void setUp() throws Exception {
super.setUp();
mContentResolver = getContext().getContentResolver();
}
/**
* Verify that writing to the GServices table in Settings provider requires permissions.
* <p>Tests Permission:
* {@link android.Manifest.permission#WRITE_GSERVICES}
*/
@MediumTest
public void testWriteGServices() {
try {
ContentValues values = new ContentValues();
values.put("url", "android");
mContentResolver.insert(Settings.Gservices.CONTENT_URI, values);
fail("Write into Gservices provider did not throw SecurityException as expected.");
} catch (SecurityException e) {
// expected
}
}
}