package com.aoleyun.sn.service; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.os.RemoteException; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import com.aoleyun.sn.SystemInfoInterface; import com.aoleyun.sn.comm.CommonConfig; import com.aoleyun.sn.comm.PackageNames; import com.aoleyun.sn.utils.CacheUtils; import com.aoleyun.sn.utils.ForegroundAppUtil; import com.aoleyun.sn.utils.JGYUtils; import com.aoleyun.sn.utils.SPUtils; import com.aoleyun.sn.utils.Utils; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class RemoteService extends Service { private String TAG = RemoteService.class.getSimpleName(); public RemoteService() { } @Override public IBinder onBind(Intent intent) { Log.e(TAG, "onBind: "); return mBinde; } @Override public int onStartCommand(Intent intent, int flags, int startId) { return super.onStartCommand(intent, flags, startId); } SystemInfoInterface.Stub mBinde = new SystemInfoInterface.Stub() { @Override public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws RemoteException { } @Override public String getSerial() throws RemoteException { return Utils.getSerial(); } @Override public List getHideIcon() throws RemoteException { List hide = JGYUtils.getInstance().getHidePackage(); return hide; } @Override public List getDisableIcon() throws RemoteException { List disable = JGYUtils.getInstance().getDisablePackage(); return disable; } @Override public String getTopAppPackage() throws RemoteException { String pkg = Settings.Global.getString(getContentResolver(), ForegroundAppUtil.TOPAPP_KEY); Log.e(TAG, "getTopAppPackage: " + pkg); return pkg; } @Override public boolean SystemPutInt(String name, int value) throws RemoteException { Log.e(TAG, "SystemPutInt: " + "name = " + name + "\t value = " + value); return Settings.System.putInt(getContentResolver(), name, value); } @Override public void setDefaultDesktop(String pkg) throws RemoteException { Log.e(TAG, "setDefaultDesktop: " + "pkg = " + pkg); SPUtils.put(RemoteService.this, "default_launcher", pkg); JGYUtils.getInstance().setDefaultDesktop(pkg); if (PackageNames.DESKTOP.equals(pkg)) { // JGYUtils.getInstance().killPackage(PackageNames.DESKTOP); try { new CacheUtils().cleanApplicationUserData(RemoteService.this, PackageNames.DESKTOP); new CacheUtils().cleanApplicationUserData(RemoteService.this, PackageNames.APPSTORE); new CacheUtils().cleanApplicationUserData(RemoteService.this, "com.aoleyunos.dop2"); } catch (Exception e) { Log.e(TAG, "onReceive: " + e.getMessage()); e.printStackTrace(); } JGYUtils.getInstance().killPackage("com.aoleyunos.dop2"); } } @Override public List getDisableApp() throws RemoteException { String disable_app_list = Settings.Global.getString(getContentResolver(), CommonConfig.AOLE_ACTION_DISABLE_APP); Log.e(TAG, "getDisableApp: " + disable_app_list); if (TextUtils.isEmpty(disable_app_list)) { return new ArrayList<>(); } else { return new ArrayList<>(Arrays.asList(disable_app_list.split(","))); } } }; }