version:1.0
fix: update:更换包名
This commit is contained in:
87
app/src/main/java/com/uiui/zyos/receiver/BootReceiver.java
Normal file
87
app/src/main/java/com/uiui/zyos/receiver/BootReceiver.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.uiui.zyos.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
private static String TAG = BootReceiver.class.getSimpleName();
|
||||
public static final String BOOT_COMPLETED = "zuoyeos.action.BOOT_COMPLETED";
|
||||
public static final String SOS = "zuoyeos.action.SOS";
|
||||
|
||||
static {
|
||||
getLockedState();
|
||||
}
|
||||
|
||||
private static void getLockedState() {
|
||||
Observable.create((ObservableOnSubscribe<Long>) emitter -> start = emitter::onNext)
|
||||
.throttleLast(1, TimeUnit.HOURS)
|
||||
.subscribe(new Observer<Long>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getLockedState", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Long aLong) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getLockedState", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getLockedState", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private interface Start {
|
||||
void onstar(long time);
|
||||
}
|
||||
|
||||
private static Start start;
|
||||
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e(TAG, "action:" + action);
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
return;
|
||||
}
|
||||
switch (action) {
|
||||
default:
|
||||
break;
|
||||
case BOOT_COMPLETED:
|
||||
// NetInterfaceManager.getInstance().getAlarmClock();
|
||||
// Intent alarmIntent = new Intent(MessageReceiver.SET_ALARMCLOCK);
|
||||
// context.sendBroadcast(alarmIntent);
|
||||
case Intent.ACTION_BOOT_COMPLETED:
|
||||
break;
|
||||
case Intent.ACTION_BATTERY_CHANGED:
|
||||
case Intent.ACTION_BATTERY_LOW:
|
||||
case Intent.ACTION_BATTERY_OKAY:
|
||||
case Intent.ACTION_POWER_CONNECTED:
|
||||
case Intent.ACTION_POWER_DISCONNECTED:
|
||||
case Intent.ACTION_DATE_CHANGED:
|
||||
case Intent.ACTION_TIME_TICK:
|
||||
case Intent.ACTION_USER_PRESENT:
|
||||
case Intent.ACTION_SCREEN_OFF:
|
||||
case Intent.ACTION_SCREEN_ON:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.uiui.zyos.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
public class InstallResultReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "InstallResultReceiver";
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// an Intent broadcast.
|
||||
//throw new UnsupportedOperationException("Not yet implemented");
|
||||
|
||||
|
||||
if (intent != null) {
|
||||
final int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS,
|
||||
PackageInstaller.STATUS_FAILURE);
|
||||
if (status == PackageInstaller.STATUS_SUCCESS) {
|
||||
// success
|
||||
String PACKAGE_NAME = intent.getStringExtra("android.content.pm.extra.PACKAGE_NAME");
|
||||
|
||||
Log.e(TAG, "APP Install Success!");
|
||||
} else {
|
||||
String msg = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE);
|
||||
}
|
||||
}
|
||||
// String s = intent.getAction();
|
||||
// Log.e("fht", s);
|
||||
// Bundle extras = intent.getExtras();
|
||||
// Set<String> ks = extras.keySet();
|
||||
// Iterator<String> iterator = ks.iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// Log.d("KEY", iterator.next());
|
||||
// }
|
||||
String STATUS = intent.getStringExtra(PackageInstaller.EXTRA_STATUS);
|
||||
String PACKAGE_NAME = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME);
|
||||
String SESSION_ID = intent.getStringExtra(PackageInstaller.EXTRA_SESSION_ID);
|
||||
String STATUS_MESSAGE = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE);
|
||||
String LEGACY_STATUS = intent.getStringExtra("android.content.pm.extra.LEGACY_STATUS");
|
||||
// Log.e("fht", STATUS);
|
||||
// Log.e("fht", PACKAGE_NAME);
|
||||
// Log.e("fht", SESSION_ID);
|
||||
// Log.e("fht", LEGACY_STATUS);
|
||||
// Log.e("fht", STATUS_MESSAGE);
|
||||
if (STATUS_MESSAGE != null && "INSTALL_SUCCEEDED".equals(STATUS_MESSAGE)) {
|
||||
// ToastUtil.show(PACKAGE_NAME + "安装成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user