正在查看: КЛ£ v1.0.0 应用的 LocationSharingService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: КЛ£ v1.0.0 应用的 LocationSharingService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package im.pggrnmxjgs.messenger;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import im.pggrnmxjgs.messenger.LocationController;
import im.pggrnmxjgs.messenger.NotificationCenter;
import im.pggrnmxjgs.tgnet.TLRPC;
import im.pggrnmxjgs.ui.LaunchActivity;
import java.util.ArrayList;
public class LocationSharingService extends Service implements NotificationCenter.NotificationCenterDelegate {
private NotificationCompat.Builder builder;
private Handler handler;
private Runnable runnable;
public LocationSharingService() {
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.liveLocationsChanged);
}
@Override
public void onCreate() {
super.onCreate();
this.handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public final void run() {
LocationSharingService.this.lambda$onCreate$1$LocationSharingService();
}
};
this.runnable = runnable;
this.handler.postDelayed(runnable, 1000L);
}
public void lambda$onCreate$1$LocationSharingService() {
this.handler.postDelayed(this.runnable, 1000L);
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
LocationSharingService.lambda$null$0();
}
});
}
static void lambda$null$0() {
for (int a = 0; a < 3; a++) {
LocationController.getInstance(a).update();
}
}
@Override
public IBinder onBind(Intent arg2) {
return null;
}
@Override
public void onDestroy() {
super.onDestroy();
Handler handler = this.handler;
if (handler != null) {
handler.removeCallbacks(this.runnable);
}
stopForeground(true);
NotificationManagerCompat.from(ApplicationLoader.applicationContext).cancel(6);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.liveLocationsChanged);
}
@Override
public void didReceivedNotification(int id, int account, Object... args) {
Handler handler;
if (id == NotificationCenter.liveLocationsChanged && (handler = this.handler) != null) {
handler.post(new Runnable() {
@Override
public final void run() {
LocationSharingService.this.lambda$didReceivedNotification$2$LocationSharingService();
}
});
}
}
public void lambda$didReceivedNotification$2$LocationSharingService() {
ArrayList<LocationController.SharingLocationInfo> infos = getInfos();
if (infos.isEmpty()) {
stopSelf();
} else {
updateNotification(true);
}
}
private ArrayList<LocationController.SharingLocationInfo> getInfos() {
ArrayList<LocationController.SharingLocationInfo> infos = new ArrayList<>();
for (int a = 0; a < 3; a++) {
ArrayList<LocationController.SharingLocationInfo> arrayList = LocationController.getInstance(a).sharingLocationsUI;
if (!arrayList.isEmpty()) {
infos.addAll(arrayList);
}
}
return infos;
}
private void updateNotification(boolean post) {
String param;
if (this.builder == null) {
return;
}
ArrayList<LocationController.SharingLocationInfo> infos = getInfos();
if (infos.size() == 1) {
LocationController.SharingLocationInfo info = infos.get(0);
int lower_id = (int) info.messageObject.getDialogId();
int currentAccount = info.messageObject.currentAccount;
if (lower_id > 0) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(Integer.valueOf(lower_id));
param = UserObject.getFirstName(user);
} else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(Integer.valueOf(-lower_id));
if (chat != null) {
param = chat.title;
} else {
param = TtmlNode.ANONYMOUS_REGION_ID;
}
}
} else {
param = LocaleController.formatPluralString("Chats", infos.size());
}
String str = String.format(LocaleController.getString("AttachLiveLocationIsSharing", R.string.AttachLiveLocationIsSharing), LocaleController.getString("AttachLiveLocation", R.string.AttachLiveLocation), param);
this.builder.setTicker(str);
this.builder.setContentText(str);
if (post) {
NotificationManagerCompat.from(ApplicationLoader.applicationContext).notify(6, this.builder.build());
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (getInfos().isEmpty()) {
stopSelf();
}
if (this.builder == null) {
Intent intent2 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
intent2.setAction("org.tmessages.openlocations");
intent2.addCategory("android.intent.category.LAUNCHER");
PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
this.builder = builder;
builder.setWhen(System.currentTimeMillis());
this.builder.setSmallIcon(R.drawable.live_loc);
this.builder.setContentIntent(contentIntent);
NotificationsController.checkOtherNotificationsChannel();
this.builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL);
this.builder.setContentTitle(LocaleController.getString("AppName", R.string.AppName));
Intent stopIntent = new Intent(ApplicationLoader.applicationContext, (Class<?>) StopLiveLocationReceiver.class);
this.builder.addAction(0, LocaleController.getString("StopLiveLocation", R.string.StopLiveLocation), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, stopIntent, 134217728));
}
updateNotification(false);
startForeground(6, this.builder.build());
return 2;
}
}