1 /* Copyright 2016 Braden Farmer
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 package com.farmerbb.taskbar.receiver;
18 import android.content.BroadcastReceiver;
19 import android.content.Context;
20 import android.content.Intent;
21 import android.content.SharedPreferences;
23 import com.farmerbb.taskbar.activity.DummyActivity;
24 import com.farmerbb.taskbar.service.NotificationService;
25 import com.farmerbb.taskbar.util.U;
27 public class BootReceiver extends BroadcastReceiver {
29 public void onReceive(Context context, Intent intent) {
30 if(Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
31 // Initialize preferences on BlissOS
32 SharedPreferences pref = U.getSharedPreferences(context);
33 if(U.isBlissOs(context) && !pref.getBoolean("bliss_os_prefs", false))
36 SharedPreferences.Editor editor = pref.edit();
38 if(!U.hasFreeformSupport(context))
39 editor.putBoolean("freeform_hack", false);
41 if(pref.getBoolean("start_on_boot", false)) {
42 editor.putBoolean("taskbar_active", true);
43 editor.putLong("time_of_service_start", System.currentTimeMillis());
46 boolean startServices = false;
48 if(!pref.getBoolean("is_hidden", false)) {
49 if(U.hasFreeformSupport(context) && pref.getBoolean("freeform_hack", false)) {
50 Intent intent2 = new Intent(context, DummyActivity.class);
51 intent2.putExtra("start_freeform_hack", true);
52 intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
54 context.startActivity(intent2);
60 Intent notificationIntent = new Intent(context, NotificationService.class);
61 notificationIntent.putExtra("start_services", startServices);
63 U.startForegroundService(context, notificationIntent);
65 editor.putBoolean("taskbar_active", U.isServiceRunning(context, NotificationService.class));