Better compatibility

You know, the kind without VerifyErrors
This commit is contained in:
Christopher Eby 2011-10-30 00:15:45 -05:00
parent bd8f4bfd12
commit 21fdda3754
4 changed files with 72 additions and 11 deletions

View File

@ -3,6 +3,7 @@
-printseeds seeds.txt
-printusage unused.txt
-optimizationpasses 5
-repackageclasses
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
@ -32,11 +33,6 @@
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
@ -55,3 +51,5 @@
-assumenosideeffects class junit.framework.Assert {
<methods>;
}
-keep public class org.kreed.vanilla.Compat*

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2011 Christopher Eby <kreed@kreed.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.kreed.vanilla;
import android.app.backup.BackupManager;
import android.content.ComponentName;
import android.content.Context;
import android.media.AudioManager;
/**
* Framework methods only in Froyo or above go here.
*/
public class CompatFroyo {
public static void registerMediaButtonEventReceiver(AudioManager manager, ComponentName receiver)
{
manager.registerMediaButtonEventReceiver(receiver);
}
public static void unregisterMediaButtonEventReceiver(AudioManager manager, ComponentName receiver)
{
manager.unregisterMediaButtonEventReceiver(receiver);
}
public static void dataChanged(Context context)
{
new BackupManager(context).dataChanged();
}
}

View File

@ -33,6 +33,10 @@ import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.view.KeyEvent;
/**
* Receives media button events and calls to PlaybackService to respond
* appropriately.
*/
public class MediaButtonReceiver extends BroadcastReceiver {
/**
* If another button event is received before this time in milliseconds
@ -175,7 +179,7 @@ public class MediaButtonReceiver extends BroadcastReceiver {
AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
ComponentName receiver = new ComponentName(context.getPackageName(), MediaButtonReceiver.class.getName());
audioManager.registerMediaButtonEventReceiver(receiver);
CompatFroyo.registerMediaButtonEventReceiver(audioManager, receiver);
}
/**
@ -190,7 +194,7 @@ public class MediaButtonReceiver extends BroadcastReceiver {
AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
ComponentName receiver = new ComponentName(context.getPackageName(), MediaButtonReceiver.class.getName());
audioManager.unregisterMediaButtonEventReceiver(receiver);
CompatFroyo.unregisterMediaButtonEventReceiver(audioManager, receiver);
}
@Override

View File

@ -22,7 +22,6 @@
package org.kreed.vanilla;
import android.app.backup.BackupManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
@ -60,7 +59,16 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public final class PlaybackService extends Service implements Handler.Callback, MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, SharedPreferences.OnSharedPreferenceChangeListener, SongTimeline.Callback {
/**
* Handles music playback and pretty much all the other work.
*/
public final class PlaybackService extends Service
implements Handler.Callback
, MediaPlayer.OnCompletionListener
, MediaPlayer.OnErrorListener
, SharedPreferences.OnSharedPreferenceChangeListener
, SongTimeline.Callback
{
/**
* Name of the state file.
*/
@ -443,8 +451,9 @@ public final class PlaybackService extends Service implements Handler.Callback,
mHeadsetPlay = settings.getBoolean(key, false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO)
new BackupManager(this).dataChanged();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
CompatFroyo.dataChanged(this);
}
}
/**
@ -892,6 +901,7 @@ public final class PlaybackService extends Service implements Handler.Callback,
}
@Override
public void onSharedPreferenceChanged(SharedPreferences settings, String key)
{
loadPreference(key);
@ -937,6 +947,7 @@ public final class PlaybackService extends Service implements Handler.Callback,
private static final int PROCESS_SONG = 13;
private static final int PROCESS_STATE = 14;
@Override
public boolean handleMessage(Message message)
{
switch (message.what) {