【質問です】こんなの表示されて消えないのですがこのスマホはコインマイニングに利用されているのでしょうか?

通知バーから、こんなダイアログがこんなダイアログが表示されてるのですが、英語が分かりません。

Google翻訳で翻訳してみます。

LineaGenuine

This device is uncertified and it didn't pass the validation.
In order to avoid malicious usage of the device's resources, LOSCoins will be mined on this device.

LineaGenuine

このデバイスは認証されておらず、検証に合格しませんでした。
デバイスのリソースの悪意のある使用を避けるため、LOSCoinはこのデバイスでマイニングされます。

先日、Googleが Uncertified な端末は排除するとかアナウンスしてましたよね。

端末の登録

...

...

え!

誰が勝手にマイニングしとんねんな!

「No」や「Cancel」を押してみると

え!

怖くなってググります。

LineaGenuine (both 15.1 and 14.1)
Our new tool allows you to feel more comfortable knowing whether you’re running a certified build. In case the device is caught running an uncertified OS, this tool will warn the user and some measures will be taken in order to guarantee you the device’s resources aren’t being misused.
If you want to disable the persistent notification, run this command from a root shell (such as adb root / recovery or terminal app) setprop persist.lineage.nofool true and reboot the device

Changelog 17 - Building Blockchains, Genuine Guarantee, and Lucky Lock – LineageOS – LineageOS Android Distribution

どうやら、エイプリルフールネタのようです。

setprop persist.lineage.nofool true && stop && start

LOSCoins on my device? Yes/No : LineageOS

ネタで良かったです。

ちなみに、Googleに認証されている端末かどうかを確認するには、「PlayStore」アプリから、

「設定」-「端末の認証」

です。

今年もよろしくおねがいします。


FCM を Firebase コンソールから使う

以前まとめておいたつもりが時間が経つとすぐに理解できない。

FCM と Notification の併用をやめてバックグラウンド受信時にうれしがる

もう、面倒くさいので忘れていても直感的すぐに使いたいので

WEBで提供されている Firebaseコンソール(コンポーザー?)から。

 

送信時の「メッセージ」は必須である

APIから送信する場合は、「データ」のみでバックグランドでしれっと端末に渡すことができるが、

WEB画面から送信する場合は「メッセージ」の入力なしでは送信ボタンがが有効化されず送信できない。

 

送信時にアプリがフォアグラウンドの場合

通知バーは表示されない。

「データ」は、端末内で稼働している Service で受け取る。

「データ」がなければ何も起きない。

 

アプリがバックグラウンドの場合

「メッセージ」と「データ」は通知バーに入る。

「データ」のタイトルは通知バーに表示され、キーと値のペアデータは PendingIntent として通知バーに入る。

 

どう使う?

端末内でプロセスが死んでない限りはフォア/バックグラウンド共に同じ挙動としたい。

フォアグラウンド受信時にも同じ挙動をするように、サービスに処理を追加。

QucikStart のサンプル内に未稼働のコードがある。


/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 */
private void sendNotification(String messageBody) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    String channelId = getString(R.string.default_notification_channel_id);
    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(this, channelId)
            .setSmallIcon(R.drawable.ic_stat_ic_notification)
            .setContentTitle("FCM Message")
            .setContentText(messageBody)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    // Since android Oreo notification channel is needed.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel channel = new NotificationChannel(channelId,
                "Channel human readable title",
                NotificationManager.IMPORTANCE_DEFAULT);
        notificationManager.createNotificationChannel(channel);
    }

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

quickstart-android/MyFirebaseMessagingService.java at master · firebase/quickstart-android

結局は、起動されるActivityでIntentを受けるような処理を記述しなければならない。 これ書くと見通し悪くなる。きもい。


if (getIntent().getExtras() != null) {
    for (String key : getIntent().getExtras().keySet()) {
        Object value = getIntent().getExtras().get(key);
        Log.d(TAG, "Key: " + key + " Value: " + value);
    }
}

quickstart-android/MainActivity.java at master · firebase/quickstart-android

直感的にそのまま使うと、単に「アプリ起動を喚起するだけのもの」になってしまいがちだのだが、きもい。


Play Services 12.0.0 で android.permission.READ_PHONE_STATE が要求されている件

Google Play Console にアップすると怒られて受け付けてくれません。

"New permissions added
WARNING
Users that have the APK with version code 19 may need to accept one or more of the android.permission.READ_PHONE_STATE and android.permission.WRITE_EXTERNAL_STORAGE permissions, which may result in them not upgrading to this version of the app."

android.permission.READ_PHONE_STATE てどんな許可内容だったか。

端末のステータスとIDの読み取り
端末の電話機能へのアクセスをアプリに許可します。これにより、電話番号、端末ID、通話中かどうか、通話相手の電話番号をアプリから特定できるようになります。

危険なパーミッションです。

「通話機能の必要ないアプリでも Play Service を利用していれば弾かれる」というような状況のようです。

android.permission.READ_PHONE_STATE added with Play Services 12.0.0 [76024034] - Visible to Public - Issue Tracker

android - Why has the READ_PHONE_STATE permission been added? - Stack Overflow

以下で回避できるようです。できました。


<uses-permission
    android:name="android.permission.READ_PHONE_STATE"
    tools:node="remove" />

なんなんでしょうね。

このような混乱はきっとこの先も増えていきそうです。

ーーー
2018-04-04: 追記
修正されているようです。
Release Notes  |  Google APIs for Android  |  Google Developers