am 5927d957: Merge "Migrate Dreams default settings to DatabaseHelper." into jb-mr1-dev
* commit '5927d957ea36744315e958ab4a9a1f095d48721c': Migrate Dreams default settings to DatabaseHelper.
This commit is contained in:
@@ -5,8 +5,6 @@ import static android.provider.Settings.Secure.SCREENSAVER_COMPONENT;
|
|||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import com.android.internal.view.IInputMethod;
|
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -16,34 +14,32 @@ import android.os.Binder;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.IWindowManager;
|
import android.view.IWindowManager;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DreamManagerService
|
public class DreamManagerService
|
||||||
extends IDreamManager.Stub
|
extends IDreamManager.Stub
|
||||||
implements ServiceConnection
|
implements ServiceConnection
|
||||||
{
|
{
|
||||||
private static final boolean DEBUG = true;
|
private static final boolean DEBUG = true;
|
||||||
private static final String TAG = "DreamManagerService";
|
private static final String TAG = "DreamManagerService";
|
||||||
|
|
||||||
final Object mLock = new Object[0];
|
final Object mLock = new Object[0];
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private IWindowManager mIWindowManager;
|
private IWindowManager mIWindowManager;
|
||||||
|
|
||||||
private ComponentName mCurrentDreamComponent;
|
private ComponentName mCurrentDreamComponent;
|
||||||
private IDreamService mCurrentDream;
|
private IDreamService mCurrentDream;
|
||||||
private Binder mCurrentDreamToken;
|
private Binder mCurrentDreamToken;
|
||||||
|
|
||||||
public DreamManagerService(Context context) {
|
public DreamManagerService(Context context) {
|
||||||
if (DEBUG) Slog.v(TAG, "DreamManagerService startup");
|
if (DEBUG) Slog.v(TAG, "DreamManagerService startup");
|
||||||
@@ -60,6 +56,7 @@ public class DreamManagerService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IDreamManager method
|
// IDreamManager method
|
||||||
|
@Override
|
||||||
public void dream() {
|
public void dream() {
|
||||||
ComponentName name = getDreamComponent();
|
ComponentName name = getDreamComponent();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
@@ -75,26 +72,26 @@ public class DreamManagerService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IDreamManager method
|
// IDreamManager method
|
||||||
|
@Override
|
||||||
public void setDreamComponent(ComponentName name) {
|
public void setDreamComponent(ComponentName name) {
|
||||||
Settings.Secure.putString(mContext.getContentResolver(), SCREENSAVER_COMPONENT, name.flattenToString());
|
Settings.Secure.putString(mContext.getContentResolver(), SCREENSAVER_COMPONENT, name.flattenToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDreamManager method
|
// IDreamManager method
|
||||||
|
@Override
|
||||||
public ComponentName getDreamComponent() {
|
public ComponentName getDreamComponent() {
|
||||||
// TODO(dsandler) don't load this every time, watch the value
|
// TODO(dsandler) don't load this every time, watch the value
|
||||||
String component = Settings.Secure.getString(mContext.getContentResolver(), SCREENSAVER_COMPONENT);
|
String component = Settings.Secure.getString(mContext.getContentResolver(), SCREENSAVER_COMPONENT);
|
||||||
if (component == null) {
|
|
||||||
component = mContext.getResources().getString(
|
|
||||||
com.android.internal.R.string.config_defaultDreamComponent);
|
|
||||||
}
|
|
||||||
if (component != null) {
|
if (component != null) {
|
||||||
return ComponentName.unflattenFromString(component);
|
return ComponentName.unflattenFromString(component);
|
||||||
} else {
|
} else {
|
||||||
|
// We rely on DatabaseHelper to set a sane default for us when the settings DB is upgraded
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDreamManager method
|
// IDreamManager method
|
||||||
|
@Override
|
||||||
public void testDream(ComponentName name) {
|
public void testDream(ComponentName name) {
|
||||||
if (DEBUG) Slog.v(TAG, "startDream name=" + name
|
if (DEBUG) Slog.v(TAG, "startDream name=" + name
|
||||||
+ " pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
|
+ " pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
|
||||||
@@ -110,6 +107,7 @@ public class DreamManagerService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IDreamManager method
|
// IDreamManager method
|
||||||
|
@Override
|
||||||
public void awaken() {
|
public void awaken() {
|
||||||
if (DEBUG) Slog.v(TAG, "awaken()");
|
if (DEBUG) Slog.v(TAG, "awaken()");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
@@ -123,6 +121,7 @@ public class DreamManagerService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IDreamManager method
|
// IDreamManager method
|
||||||
|
@Override
|
||||||
public boolean isDreaming() {
|
public boolean isDreaming() {
|
||||||
return mCurrentDream != null;
|
return mCurrentDream != null;
|
||||||
}
|
}
|
||||||
@@ -141,14 +140,14 @@ public class DreamManagerService
|
|||||||
mCurrentDreamComponent = componentName;
|
mCurrentDreamComponent = componentName;
|
||||||
mCurrentDreamToken = new Binder();
|
mCurrentDreamToken = new Binder();
|
||||||
try {
|
try {
|
||||||
if (DEBUG) Slog.v(TAG, "Adding window token: " + mCurrentDreamToken
|
if (DEBUG) Slog.v(TAG, "Adding window token: " + mCurrentDreamToken
|
||||||
+ " for window type: " + WindowManager.LayoutParams.TYPE_DREAM);
|
+ " for window type: " + WindowManager.LayoutParams.TYPE_DREAM);
|
||||||
mIWindowManager.addWindowToken(mCurrentDreamToken,
|
mIWindowManager.addWindowToken(mCurrentDreamToken,
|
||||||
WindowManager.LayoutParams.TYPE_DREAM);
|
WindowManager.LayoutParams.TYPE_DREAM);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "Unable to add window token. Proceed at your own risk.");
|
Slog.w(TAG, "Unable to add window token. Proceed at your own risk.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mContext.bindService(intent, this, Context.BIND_AUTO_CREATE)) {
|
if (!mContext.bindService(intent, this, Context.BIND_AUTO_CREATE)) {
|
||||||
Slog.w(TAG, "unable to bind service: " + componentName);
|
Slog.w(TAG, "unable to bind service: " + componentName);
|
||||||
}
|
}
|
||||||
@@ -172,7 +171,7 @@ public class DreamManagerService
|
|||||||
if (DEBUG) Slog.v(TAG, "disconnected: " + name + " service: " + mCurrentDream);
|
if (DEBUG) Slog.v(TAG, "disconnected: " + name + " service: " + mCurrentDream);
|
||||||
// Only happens in exceptional circumstances
|
// Only happens in exceptional circumstances
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
|
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
|
||||||
|
|||||||
@@ -853,8 +853,6 @@
|
|||||||
|
|
||||||
<!-- enable screen saver feature -->
|
<!-- enable screen saver feature -->
|
||||||
<bool name="config_enableDreams">true</bool>
|
<bool name="config_enableDreams">true</bool>
|
||||||
<!-- Name of screensaver components to look for if none has been chosen by the user -->
|
|
||||||
<string name="config_defaultDreamComponent" translatable="false">com.google.android.deskclock/com.android.deskclock.Screensaver</string>
|
|
||||||
|
|
||||||
<!-- Base "touch slop" value used by ViewConfiguration as a
|
<!-- Base "touch slop" value used by ViewConfiguration as a
|
||||||
movement threshold where scrolling should begin. -->
|
movement threshold where scrolling should begin. -->
|
||||||
|
|||||||
@@ -1557,7 +1557,6 @@
|
|||||||
<java-symbol type="style" name="Theme.Toast" />
|
<java-symbol type="style" name="Theme.Toast" />
|
||||||
<java-symbol type="xml" name="storage_list" />
|
<java-symbol type="xml" name="storage_list" />
|
||||||
<java-symbol type="bool" name="config_enableDreams" />
|
<java-symbol type="bool" name="config_enableDreams" />
|
||||||
<java-symbol type="string" name="config_defaultDreamComponent" />
|
|
||||||
<java-symbol type="string" name="enable_explore_by_touch_warning_title" />
|
<java-symbol type="string" name="enable_explore_by_touch_warning_title" />
|
||||||
<java-symbol type="string" name="enable_explore_by_touch_warning_message" />
|
<java-symbol type="string" name="enable_explore_by_touch_warning_message" />
|
||||||
|
|
||||||
|
|||||||
@@ -151,4 +151,12 @@
|
|||||||
<!-- Number of retries for connecting to DHCP.
|
<!-- Number of retries for connecting to DHCP.
|
||||||
Value here is the same as WifiStateMachine.DEFAULT_MAX_DHCP_RETRIES -->
|
Value here is the same as WifiStateMachine.DEFAULT_MAX_DHCP_RETRIES -->
|
||||||
<integer name="def_max_dhcp_retries">9</integer>
|
<integer name="def_max_dhcp_retries">9</integer>
|
||||||
|
|
||||||
|
<!-- Dreams (screen saver) default settings -->
|
||||||
|
<!-- Whether the feature is enabled when charging (Settings.Secure.SCREENSAVER_ENABLED) -->
|
||||||
|
<bool name="def_screensaver_enabled">true</bool>
|
||||||
|
<!-- Whether the feature activates when docked (SCREENSAVER_ACTIVATE_ON_DOCK) -->
|
||||||
|
<bool name="def_screensaver_activate_on_dock">true</bool>
|
||||||
|
<!-- ComponentName of the default screen saver (Settings.Secure.SCREENSAVER_COMPONENT) -->
|
||||||
|
<string name="def_screensaver_component">com.google.android.deskclock/com.android.deskclock.Screensaver</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
|
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
|
||||||
// is properly propagated through your change. Not doing so will result in a loss of user
|
// is properly propagated through your change. Not doing so will result in a loss of user
|
||||||
// settings.
|
// settings.
|
||||||
private static final int DATABASE_VERSION = 79;
|
private static final int DATABASE_VERSION = 80;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@@ -1073,6 +1073,30 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
upgradeVersion = 79;
|
upgradeVersion = 79;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vvv Jelly Bean MR1 changes begin here vvv
|
||||||
|
|
||||||
|
if (upgradeVersion == 79) {
|
||||||
|
// update screensaver settings
|
||||||
|
db.beginTransaction();
|
||||||
|
SQLiteStatement stmt = null;
|
||||||
|
try {
|
||||||
|
stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)"
|
||||||
|
+ " VALUES(?,?);");
|
||||||
|
loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ENABLED,
|
||||||
|
R.bool.def_screensaver_enabled);
|
||||||
|
loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK,
|
||||||
|
R.bool.def_screensaver_activate_on_dock);
|
||||||
|
loadStringSetting(stmt, Settings.Secure.SCREENSAVER_COMPONENT,
|
||||||
|
R.string.def_screensaver_component);
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
db.endTransaction();
|
||||||
|
if (stmt != null) stmt.close();
|
||||||
|
}
|
||||||
|
upgradeVersion = 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// *** Remember to update DATABASE_VERSION above!
|
// *** Remember to update DATABASE_VERSION above!
|
||||||
|
|
||||||
if (upgradeVersion != currentVersion) {
|
if (upgradeVersion != currentVersion) {
|
||||||
|
|||||||
Reference in New Issue
Block a user