Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
TileReceiver: Fix crash below Android N
Browse files Browse the repository at this point in the history
Signed-off-by: Fung Go <fython@163.com>
  • Loading branch information
fython committed Jan 15, 2017
1 parent 7d6e324 commit 5c37691
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "info.papdt.blackblub"
minSdkVersion 21
targetSdkVersion 25
versionCode 8
versionName "1.2.0"
versionCode 9
versionName "1.2.1"
}
buildTypes {
release {
Expand Down
8 changes: 7 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@
}
-keepclassmembers class **.R$* {
public static <fields>;
}
}

-keep class info.papdt.blackblub.receiver.** {*;}
-keep class info.papdt.blackblub.services.** {*;}
-keep class info.papdt.blackblub.ui.** {*;}
-keep class info.papdt.blackblub.ui.LaunchActivity$MessageReceiver {*;}
-keep class info.papdt.blackblub.ui.shortcut.ToggleActivity$MessageReceiver {*;}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;

import info.papdt.blackblub.C;
Expand Down Expand Up @@ -49,9 +50,11 @@ public void onReceive(Context context, Intent intent) {
break;
}

Intent tileUpdateIntent = new Intent(context, MaskTileService.class);
tileUpdateIntent.putExtra(C.EXTRA_ACTION, action);
context.startService(tileUpdateIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Intent tileUpdateIntent = new Intent(context, MaskTileService.class);
tileUpdateIntent.putExtra(C.EXTRA_ACTION, action);
context.startService(tileUpdateIntent);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package info.papdt.blackblub.services;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Icon;
import android.os.Build;
Expand All @@ -12,6 +13,7 @@
import info.papdt.blackblub.R;
import info.papdt.blackblub.receiver.TileReceiver;

@SuppressLint("Override")
@TargetApi(Build.VERSION_CODES.N)
public class MaskTileService extends TileService {

Expand All @@ -23,6 +25,7 @@ public void onClick(){
Log.i(TAG, "Tile service onClick method called");
super.onClick();
Tile tile = getQsTile();
if (tile == null) return;
int status = tile.getState();
Log.i(TAG, "status:"+status+"\t receive");

Expand Down

0 comments on commit 5c37691

Please sign in to comment.