version:3.9
fix:修复解锁后无限重置的bug update:更换图标,增加解锁后显示所有app
This commit is contained in:
@@ -24,6 +24,7 @@ import android.animation.ValueAnimator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.WallpaperManager;
|
||||
import android.app.role.RoleManager;
|
||||
import android.appwidget.AppWidgetHostView;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
@@ -49,6 +50,7 @@ import android.os.Handler;
|
||||
import android.os.Parcelable;
|
||||
import android.os.Process;
|
||||
import android.os.StrictMode;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.TextKeyListener;
|
||||
@@ -166,7 +168,9 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@@ -421,7 +425,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
|
||||
if (!isDefaultHome()) {
|
||||
setDefaultL();
|
||||
// setDefaultL();
|
||||
setRoleHolderAsUser(this, BuildConfig.APPLICATION_ID);
|
||||
}
|
||||
SharedPreferences sharedPref = getPreferences(MODE_PRIVATE);
|
||||
int i = sharedPref.getInt("SetWallPaper", 0);
|
||||
@@ -572,6 +577,39 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
}
|
||||
|
||||
// private void setDefault() {
|
||||
// String mRoleName ="android.app.role.HOME";
|
||||
// final Intent intent = new Intent(Intent.ACTION_MANAGE_DEFAULT_APP)
|
||||
// .putExtra(Intent.EXTRA_ROLE_NAME, mRoleName);
|
||||
// startActivity(intent);
|
||||
// }
|
||||
|
||||
public void setRoleHolderAsUser(Context context, String packageName) {
|
||||
String roleName = "android.app.role.HOME";
|
||||
boolean add = true;
|
||||
int flags = 0;
|
||||
UserHandle user = Process.myUserHandle();
|
||||
|
||||
Log.i("settingssssssstemf", (add ? "Adding" : "Removing") + " package as role holder, role: "
|
||||
+ roleName + ", package: " + packageName);
|
||||
|
||||
RoleManager roleManager = context.getSystemService(RoleManager.class);
|
||||
Executor executor = context.getMainExecutor();
|
||||
Consumer<Boolean> callback = successful -> {
|
||||
if (successful) {
|
||||
Log.d("settingssssssstemf", "Package " + (add ? "added" : "removed")
|
||||
+ " as role holder, role: " + roleName + ", package: " + packageName);
|
||||
} else {
|
||||
Log.d("settingssssssstemf", "Failed to " + (add ? "add" : "remove")
|
||||
+ " package as role holder, role: " + roleName + ", package: "
|
||||
+ packageName);
|
||||
}
|
||||
};
|
||||
|
||||
roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback);
|
||||
Log.i("settingssssssstemf", "addRoleHolderAsUser done");
|
||||
}
|
||||
|
||||
private TimeChangedReceiver mTimeChangedReceiver;
|
||||
|
||||
//监听时间和日期变化
|
||||
|
||||
Reference in New Issue
Block a user