From: David A. Velasco Date: Fri, 18 Jan 2013 12:33:08 +0000 (+0100) Subject: Added helper app to work around the issue of lost credentials at boot time affecting... X-Git-Tag: oc-android-1.4.3~63 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/0ad4898ccf0265577c5c0309021c878823a3dfc0?ds=inline;hp=--cc Added helper app to work around the issue of lost credentials at boot time affecting ownCloud apps installed from the Google Play Store in Android 4.1.x --- 0ad4898ccf0265577c5c0309021c878823a3dfc0 diff --git a/oc_jb_workaround/.classpath b/oc_jb_workaround/.classpath new file mode 100644 index 00000000..3f9691c5 --- /dev/null +++ b/oc_jb_workaround/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/oc_jb_workaround/.gitignore b/oc_jb_workaround/.gitignore new file mode 100644 index 00000000..0105cb34 --- /dev/null +++ b/oc_jb_workaround/.gitignore @@ -0,0 +1,19 @@ +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Mac .DS_Store files +.DS_Store diff --git a/oc_jb_workaround/.project b/oc_jb_workaround/.project new file mode 100644 index 00000000..54714bb1 --- /dev/null +++ b/oc_jb_workaround/.project @@ -0,0 +1,33 @@ + + + owncloud-android-workaround-accounts + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/oc_jb_workaround/.settings/org.eclipse.jdt.core.prefs b/oc_jb_workaround/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..b080d2dd --- /dev/null +++ b/oc_jb_workaround/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/oc_jb_workaround/AndroidManifest.xml b/oc_jb_workaround/AndroidManifest.xml new file mode 100644 index 00000000..af29747a --- /dev/null +++ b/oc_jb_workaround/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/oc_jb_workaround/README.md b/oc_jb_workaround/README.md new file mode 100644 index 00000000..cddf3bda --- /dev/null +++ b/oc_jb_workaround/README.md @@ -0,0 +1,10 @@ +ownCloud Jelly Bean Workaround +============================== + +Helper app to work around the problem of lost credentials at reboot time found +in devices with Android 4.1.x. + +Only needed for ownCloud apps installed from the Google Play Store. + +See more information about the bug here: +http://code.google.com/p/android/issues/detail?id=34880 \ No newline at end of file diff --git a/oc_jb_workaround/proguard-project.txt b/oc_jb_workaround/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/oc_jb_workaround/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/oc_jb_workaround/project.properties b/oc_jb_workaround/project.properties new file mode 100644 index 00000000..9b84a6b4 --- /dev/null +++ b/oc_jb_workaround/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-16 diff --git a/oc_jb_workaround/res/drawable-hdpi/oc_icon.png b/oc_jb_workaround/res/drawable-hdpi/oc_icon.png new file mode 100644 index 00000000..e388c7be Binary files /dev/null and b/oc_jb_workaround/res/drawable-hdpi/oc_icon.png differ diff --git a/oc_jb_workaround/res/drawable-hdpi/oc_workaround_icon.png b/oc_jb_workaround/res/drawable-hdpi/oc_workaround_icon.png new file mode 100644 index 00000000..32985e36 Binary files /dev/null and b/oc_jb_workaround/res/drawable-hdpi/oc_workaround_icon.png differ diff --git a/oc_jb_workaround/res/drawable-ldpi/oc_icon.png b/oc_jb_workaround/res/drawable-ldpi/oc_icon.png new file mode 100644 index 00000000..11cf0ab1 Binary files /dev/null and b/oc_jb_workaround/res/drawable-ldpi/oc_icon.png differ diff --git a/oc_jb_workaround/res/drawable-ldpi/oc_workaround_icon.png b/oc_jb_workaround/res/drawable-ldpi/oc_workaround_icon.png new file mode 100644 index 00000000..03fa38be Binary files /dev/null and b/oc_jb_workaround/res/drawable-ldpi/oc_workaround_icon.png differ diff --git a/oc_jb_workaround/res/drawable-mdpi/oc_icon.png b/oc_jb_workaround/res/drawable-mdpi/oc_icon.png new file mode 100644 index 00000000..6997c7e4 Binary files /dev/null and b/oc_jb_workaround/res/drawable-mdpi/oc_icon.png differ diff --git a/oc_jb_workaround/res/drawable-mdpi/oc_workaround_icon.png b/oc_jb_workaround/res/drawable-mdpi/oc_workaround_icon.png new file mode 100644 index 00000000..78cd3ed4 Binary files /dev/null and b/oc_jb_workaround/res/drawable-mdpi/oc_workaround_icon.png differ diff --git a/oc_jb_workaround/res/drawable-xhdpi/oc_icon.png b/oc_jb_workaround/res/drawable-xhdpi/oc_icon.png new file mode 100644 index 00000000..e388c7be Binary files /dev/null and b/oc_jb_workaround/res/drawable-xhdpi/oc_icon.png differ diff --git a/oc_jb_workaround/res/drawable-xhdpi/oc_workaround_icon.png b/oc_jb_workaround/res/drawable-xhdpi/oc_workaround_icon.png new file mode 100644 index 00000000..d8a924c3 Binary files /dev/null and b/oc_jb_workaround/res/drawable-xhdpi/oc_workaround_icon.png differ diff --git a/oc_jb_workaround/res/values-v11/styles.xml b/oc_jb_workaround/res/values-v11/styles.xml new file mode 100644 index 00000000..541752f6 --- /dev/null +++ b/oc_jb_workaround/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/oc_jb_workaround/res/values-v14/styles.xml b/oc_jb_workaround/res/values-v14/styles.xml new file mode 100644 index 00000000..f20e0150 --- /dev/null +++ b/oc_jb_workaround/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/oc_jb_workaround/res/values/strings.xml b/oc_jb_workaround/res/values/strings.xml new file mode 100644 index 00000000..177c0536 --- /dev/null +++ b/oc_jb_workaround/res/values/strings.xml @@ -0,0 +1,6 @@ + + + + ownCloud Jelly Bean Workaround for lost credentials + + \ No newline at end of file diff --git a/oc_jb_workaround/res/values/styles.xml b/oc_jb_workaround/res/values/styles.xml new file mode 100644 index 00000000..4a10ca49 --- /dev/null +++ b/oc_jb_workaround/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/oc_jb_workaround/res/xml/authenticator.xml b/oc_jb_workaround/res/xml/authenticator.xml new file mode 100644 index 00000000..a62aa212 --- /dev/null +++ b/oc_jb_workaround/res/xml/authenticator.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java b/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java new file mode 100644 index 00000000..2d81f655 --- /dev/null +++ b/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java @@ -0,0 +1,103 @@ +/* ownCloud Jelly Bean Workaround for lost credentials + * + * Copyright (C) 2013 ownCloud Inc. + */ + +package com.owncloud.android.workaround.accounts; + +import android.accounts.AbstractAccountAuthenticator; +import android.accounts.Account; +import android.accounts.AccountAuthenticatorResponse; +import android.accounts.AccountManager; +import android.accounts.NetworkErrorException; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.IBinder; + +public class AccountAuthenticatorService extends Service { + + private AccountAuthenticator mAuthenticator; + static final public String ACCOUNT_TYPE = "owncloud"; + + @Override + public void onCreate() { + super.onCreate(); + mAuthenticator = new AccountAuthenticator(this); + } + + @Override + public IBinder onBind(Intent intent) { + return mAuthenticator.getIBinder(); + } + + + public static class AccountAuthenticator extends AbstractAccountAuthenticator { + + public AccountAuthenticator(Context context) { + super(context); + } + + @Override + public Bundle addAccount(AccountAuthenticatorResponse response, + String accountType, String authTokenType, + String[] requiredFeatures, Bundle options) + throws NetworkErrorException { + return getCommonResultBundle(); + } + + + @Override + public Bundle confirmCredentials(AccountAuthenticatorResponse response, + Account account, Bundle options) throws NetworkErrorException { + return getCommonResultBundle(); + } + + @Override + public Bundle editProperties(AccountAuthenticatorResponse response, + String accountType) { + return getCommonResultBundle(); + } + + @Override + public Bundle getAuthToken(AccountAuthenticatorResponse response, + Account account, String authTokenType, Bundle options) + throws NetworkErrorException { + return getCommonResultBundle(); + } + + @Override + public String getAuthTokenLabel(String authTokenType) { + return ""; + } + + @Override + public Bundle hasFeatures(AccountAuthenticatorResponse response, + Account account, String[] features) throws NetworkErrorException { + return getCommonResultBundle(); + } + + @Override + public Bundle updateCredentials(AccountAuthenticatorResponse response, + Account account, String authTokenType, Bundle options) + throws NetworkErrorException { + return getCommonResultBundle(); + } + + @Override + public Bundle getAccountRemovalAllowed( + AccountAuthenticatorResponse response, Account account) + throws NetworkErrorException { + return getCommonResultBundle(); + } + + private Bundle getCommonResultBundle() { + Bundle resultBundle = new Bundle(); + resultBundle.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION); + resultBundle.putString(AccountManager.KEY_ERROR_MESSAGE, "This is just a workaround, not a real account authenticator"); + return resultBundle; + } + + } +}