OSDN Git Service

Merge "Bug AOSP 12476: Manual time setting resets seconds to 0."
authorGilles Debunne <debunne@google.com>
Fri, 29 Jul 2011 18:46:56 +0000 (11:46 -0700)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Fri, 29 Jul 2011 18:46:56 +0000 (11:46 -0700)
14 files changed:
AndroidManifest.xml
res/layout/preference_inputmethod.xml
res/layout/set_backup_pw.xml [new file with mode: 0644]
res/values/strings.xml
res/xml/privacy_settings.xml
src/com/android/settings/PrivacySettings.java
src/com/android/settings/SetFullBackupPassword.java [new file with mode: 0644]
src/com/android/settings/bluetooth/BluetoothPairingRequest.java
src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
src/com/android/settings/bluetooth/CachedBluetoothDevice.java
src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
src/com/android/settings/bluetooth/DockEventReceiver.java
src/com/android/settings/bluetooth/DockService.java

index 5302eb0..4118f32 100644 (file)
                 android:resource="@id/privacy_settings" />
         </activity>
 
+        <activity android:name="SetFullBackupPassword"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge"
+                android:exported="false">
+        </activity>
+
         <activity android:name="CredentialStorage"
                 android:theme="@style/Transparent"
                 android:configChanges="orientation|keyboardHidden|screenSize">
index 227b165..0edc060 100644 (file)
@@ -78,6 +78,7 @@
         android:paddingLeft="15dip"
         android:paddingRight="?android:attr/scrollbarSize"
         android:src="@drawable/ic_sysbar_quicksettings"
+        android:contentDescription="@string/input_method_settings_button"
         android:layout_gravity="center"
         android:clickable="true"
         android:focusable="true"
diff --git a/res/layout/set_backup_pw.xml b/res/layout/set_backup_pw.xml
new file mode 100644 (file)
index 0000000..3743c81
--- /dev/null
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:padding="16dip"
+    >
+
+    <TextView
+            android:id="@+id/prompt1"
+            android:text="@string/current_backup_pw_prompt"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content" />
+
+    <EditText
+            android:id="@+id/current_backup_pw"
+            android:layout_below="@id/prompt1"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:singleLine="true"
+            android:password="true" />
+
+    <TextView
+            android:id="@+id/prompt2"
+            android:layout_below="@id/current_backup_pw"
+            android:text="@string/new_backup_pw_prompt"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content" />
+
+    <EditText
+            android:id="@+id/new_backup_pw"
+            android:layout_below="@id/prompt2"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:singleLine="true"
+            android:password="true" />
+
+    <TextView
+            android:id="@+id/prompt3"
+            android:layout_below="@id/new_backup_pw"
+            android:text="@string/confirm_new_backup_pw_prompt"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content" />
+
+    <EditText
+            android:id="@+id/confirm_new_backup_pw"
+            android:layout_below="@id/prompt3"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:singleLine="true"
+            android:password="true" />
+
+    <Button
+            android:id="@+id/backup_pw_cancel_button"
+            android:layout_below="@id/confirm_new_backup_pw"
+            android:text="@string/backup_pw_cancel_button_text"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content" />
+
+    <Button
+            android:id="@+id/backup_pw_set_button"
+            android:layout_below="@id/confirm_new_backup_pw"
+            android:layout_toRightOf="@id/backup_pw_cancel_button"
+            android:text="@string/backup_pw_set_button_text"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content" />
+
+</RelativeLayout>
index eef3792..cf35ba8 100644 (file)
@@ -2587,6 +2587,8 @@ found in the list of installed applications.</string>
     <string name="configure_input_method">Configure input methods</string>
     <!-- Title for settings of each IME [CHAR LIMIT=25] -->
     <string name="input_method_settings">Settings</string>
+    <!-- Spoken description for IME settings image button [CHAR LIMIT=NONE] -->
+    <string name="input_method_settings_button">Settings</string>
     <!-- Title for settings of active input methods in each IME [CHAR LIMIT=35] -->
     <string name="active_input_method_subtypes">Active input methods</string>
     <!-- Title for settings whether or not the framework will select input methods in an IME based on the current system locale. [CHAR LIMIT=35] -->
@@ -3080,6 +3082,14 @@ found in the list of installed applications.</string>
     <string name="auto_restore_title">Automatic restore</string>
     <!-- Summary text of the "automatic restore" setting -->
     <string name="auto_restore_summary">If I reinstall an application, restore backed up settings or other data</string>
+
+    <!-- Local backup password menu title [CHAR LIMIT=25] -->
+    <string name="local_backup_password_title">Local backup password</string>
+    <!-- Summary text of the "local backup password" setting when the user has not supplied a password -->
+    <string name="local_backup_password_summary_none">Local full backups are not currently protected.</string>
+    <!-- Summary text of the "local backup password" setting when the user has already supplied a password -->
+    <string name="local_backup_password_summary_change">Select to change or remove the password for local full backups</string>
+
     <!-- Dialog title for confirmation to erase backup data from server -->
     <string name="backup_erase_dialog_title">Backup</string>
     <!-- Dialog title for confirmation to erase backup data from server -->
@@ -3593,4 +3603,17 @@ found in the list of installed applications.</string>
 
     <!--  Title for spelling correction settings -->
     <string name="spellcheckers_settings_title">Spelling correction</string>
+
+    <!-- Prompt for the user to enter their current full-backup password -->
+    <string name="current_backup_pw_prompt">Enter your current full backup password here</string>
+    <!-- Prompt for the user to enter a new full-backup password -->
+    <string name="new_backup_pw_prompt">Enter a new password for full backups here</string>
+    <!-- Prompt for the user to confirm the new full-backup password by re-entering it -->
+    <string name="confirm_new_backup_pw_prompt">Please re-enter your new full backup password here</string>
+
+    <!-- Button label for setting the user's new full-backup password -->
+    <string name="backup_pw_set_button_text">Set backup password</string>
+    <!-- Button label for cancelling the new-password operation and retaining the user's previous full-backup password -->
+    <string name="backup_pw_cancel_button_text">Cancel</string>
+
 </resources>
index 54d88f7..60efef6 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 The Android Open Source Project
+<!-- Copyright (C) 2009-2011 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.
                 android:title="@string/auto_restore_title"
                 android:summary="@string/auto_restore_summary"
                 android:persistent="false" />
+        <PreferenceScreen
+                android:key="local_backup_password"
+                android:title="@string/local_backup_password_title"
+                android:summary="@string/local_backup_password_summary_none"
+                android:persistent="false" >
+            <intent
+                    android:action="android.settings.privacy.SET_FULL_BACKUP_PASSWORD"
+                    android:targetPackage="com.android.settings"
+                    android:targetClass="com.android.settings.SetFullBackupPassword" />
+        </PreferenceScreen>
     </PreferenceCategory>
 
     <PreferenceCategory
index 28dc93a..6759500 100644 (file)
@@ -43,11 +43,13 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
     private static final String BACKUP_DATA = "backup_data";
     private static final String AUTO_RESTORE = "auto_restore";
     private static final String CONFIGURE_ACCOUNT = "configure_account";
+    private static final String LOCAL_BACKUP_PASSWORD = "local_backup_password";
     private IBackupManager mBackupManager;
     private CheckBoxPreference mBackup;
     private CheckBoxPreference mAutoRestore;
     private Dialog mConfirmDialog;
     private PreferenceScreen mConfigure;
+    private PreferenceScreen mPassword;
 
     private static final int DIALOG_ERASE_BACKUP = 2;
     private int mDialogType;
@@ -64,6 +66,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
         mBackup = (CheckBoxPreference) screen.findPreference(BACKUP_DATA);
         mAutoRestore = (CheckBoxPreference) screen.findPreference(AUTO_RESTORE);
         mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_ACCOUNT);
+        mPassword = (PreferenceScreen) screen.findPreference(LOCAL_BACKUP_PASSWORD);
 
         // Vendor specific
         if (getActivity().getPackageManager().
@@ -158,7 +161,9 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
         mConfigure.setEnabled(configureEnabled);
         mConfigure.setIntent(configIntent);
         setConfigureSummary(configSummary);
-    }
+
+        updatePasswordSummary();
+}
 
     private void setConfigureSummary(String summary) {
         if (summary != null) {
@@ -178,6 +183,18 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
         }
     }
 
+    private void updatePasswordSummary() {
+        try {
+            if (mBackupManager.hasBackupPassword()) {
+                mPassword.setSummary(R.string.local_backup_password_summary_change);
+            } else {
+                mPassword.setSummary(R.string.local_backup_password_summary_none);
+            }
+        } catch (RemoteException e) {
+            // Not much we can do here
+        }
+    }
+
     public void onClick(DialogInterface dialog, int which) {
         if (which == DialogInterface.BUTTON_POSITIVE) {
             //updateProviders();
diff --git a/src/com/android/settings/SetFullBackupPassword.java b/src/com/android/settings/SetFullBackupPassword.java
new file mode 100644 (file)
index 0000000..9f3f29f
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2011 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.settings;
+
+import android.app.Activity;
+import android.app.backup.IBackupManager;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class SetFullBackupPassword extends Activity {
+    static final String TAG = "SetFullBackupPassword";
+
+    IBackupManager mBackupManager;
+    TextView mCurrentPw, mNewPw, mConfirmNewPw;
+    Button mCancel, mSet;
+
+    OnClickListener mButtonListener = new OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            if (v == mSet) {
+                final String curPw = mCurrentPw.getText().toString();
+                final String newPw = mNewPw.getText().toString();
+                final String confirmPw = mConfirmNewPw.getText().toString();
+
+                if (!newPw.equals(confirmPw)) {
+                    // Mismatch between new pw and its confirmation re-entry
+Log.i(TAG, "password mismatch");
+                    Toast.makeText(SetFullBackupPassword.this,
+                            "!!! New password and confirmation don't match !!!",
+                            Toast.LENGTH_LONG).show();
+                    return;
+                }
+
+                // TODO: should we distinguish cases of has/hasn't set a pw before?
+
+                if (setBackupPassword(curPw, newPw)) {
+                    // success
+Log.i(TAG, "password set successfully");
+                    Toast.makeText(SetFullBackupPassword.this,
+                            "!!! New backup password set !!!",
+                            Toast.LENGTH_LONG).show();
+                    finish();
+                } else {
+                    // failure -- bad existing pw, usually
+Log.i(TAG, "failure; password mismatch?");
+                    Toast.makeText(SetFullBackupPassword.this,
+                            "!!! Failure setting backup password !!!",
+                            Toast.LENGTH_LONG).show();
+                }
+            } else if (v == mCancel) {
+                finish();
+            } else {
+                Log.w(TAG, "Click on unknown view");
+            }
+        }
+    };
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService("backup"));
+
+        setContentView(R.layout.set_backup_pw);
+
+        mCurrentPw = (TextView) findViewById(R.id.current_backup_pw);
+        mNewPw = (TextView) findViewById(R.id.new_backup_pw);
+        mConfirmNewPw = (TextView) findViewById(R.id.confirm_new_backup_pw);
+
+        mCancel = (Button) findViewById(R.id.backup_pw_cancel_button);
+        mSet = (Button) findViewById(R.id.backup_pw_set_button);
+
+        mCancel.setOnClickListener(mButtonListener);
+        mSet.setOnClickListener(mButtonListener);
+    }
+
+    private boolean setBackupPassword(String currentPw, String newPw) {
+        try {
+            return mBackupManager.setBackupPassword(currentPw, newPw);
+        } catch (RemoteException e) {
+            Log.e(TAG, "Unable to communicate with backup manager");
+            return false;
+        }
+    }
+}
index de96d71..838e7b1 100644 (file)
@@ -82,7 +82,7 @@ public final class BluetoothPairingRequest extends BroadcastReceiver {
 
                 String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
                 if (TextUtils.isEmpty(name)) {
-                    name = device != null ? device.getName() :
+                    name = device != null ? device.getAliasName() :
                             context.getString(android.R.string.unknownName);
                 }
 
index 1a0965c..4d96140 100644 (file)
@@ -130,7 +130,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements
     }
 
     private String createConnectionDisplayText() {
-        String mRemoteName = mDevice != null ? mDevice.getName() : null;
+        String mRemoteName = mDevice != null ? mDevice.getAliasName() : null;
 
         if (mRemoteName == null) mRemoteName = getString(R.string.unknown);
         String mMessage1 = getString(R.string.bluetooth_connection_dialog_text,
@@ -139,7 +139,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements
     }
 
     private String createPbapDisplayText() {
-        String mRemoteName = mDevice != null ? mDevice.getName() : null;
+        String mRemoteName = mDevice != null ? mDevice.getAliasName() : null;
 
         if (mRemoteName == null) mRemoteName = getString(R.string.unknown);
         String mMessage1 = getString(R.string.bluetooth_pb_acceptance_dialog_text,
index c769ba6..51055af 100644 (file)
@@ -83,7 +83,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
                 Notification notification = new Notification(android.R.drawable.stat_sys_data_bluetooth,
                     context.getString(R.string.bluetooth_connection_permission_request),
                     System.currentTimeMillis());
-                String deviceName = device != null ? device.getName() : null;
+                String deviceName = device != null ? device.getAliasName() : null;
                 notification.setLatestEventInfo(context,
                     context.getString(R.string.bluetooth_connection_permission_request),
                     context.getString(R.string.bluetooth_connection_notif_message, deviceName),
index 846c379..8082314 100644 (file)
@@ -326,8 +326,8 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
                 mName = mDevice.getAddress();
             } else {
                 mName = name;
+                mDevice.setAlias(name);
             }
-            // TODO: save custom device name in preferences
             dispatchAttributesChanged();
         }
     }
@@ -338,7 +338,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
     }
 
     private void fetchName() {
-        mName = mDevice.getName();
+        mName = mDevice.getAliasName();
 
         if (TextUtils.isEmpty(mName)) {
             mName = mDevice.getAddress();
@@ -422,7 +422,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
         mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles);
 
         if (DEBUG) {
-            Log.e(TAG, "updating profiles for " + mDevice.getName());
+            Log.e(TAG, "updating profiles for " + mDevice.getAliasName());
             BluetoothClass bluetoothClass = mDevice.getBluetoothClass();
 
             if (bluetoothClass != null) Log.v(TAG, "Class: " + bluetoothClass.toString());
index ab71ece..f293f50 100644 (file)
@@ -104,7 +104,7 @@ final class CachedBluetoothDeviceManager {
             return cachedDevice.getName();
         }
 
-        String name = device.getName();
+        String name = device.getAliasName();
         if (name != null) {
             return name;
         }
index 6ecbef6..d18348f 100644 (file)
@@ -54,7 +54,7 @@ public final class DockEventReceiver extends BroadcastReceiver {
 
         if (DEBUG) {
             Log.d(TAG, "Action: " + intent.getAction() + " State:" + state + " Device: "
-                    + (device == null ? "null" : device.getName()));
+                    + (device == null ? "null" : device.getAliasName()));
         }
 
         if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())
index b457706..f0644c3 100644 (file)
@@ -424,7 +424,7 @@ public final class DockService extends Service implements ServiceListener {
 
         if (DEBUG) {
             Log.d(TAG, "Action: " + intent.getAction() + " State:" + state
-                    + " Device: " + (device == null ? "null" : device.getName()));
+                    + " Device: " + (device == null ? "null" : device.getAliasName()));
         }
 
         if (device == null) {