android: bugfix in GUI logging. since seperation of service and UI processes the static logging variable has to be initialized in both.

This commit is contained in:
Joachim Fritzsch 2014-03-04 13:48:18 +01:00
parent 3d8993b4dd
commit c74586485e
3 changed files with 14 additions and 4 deletions

View File

@ -55,7 +55,7 @@ public class NoticesFragment extends Fragment {
@Override
public void onResume() {
Log.d(Logging.TAG, "NoticesFragment onResume()");
if(Logging.DEBUG) Log.d(Logging.TAG, "NoticesFragment onResume()");
getActivity().registerReceiver(mClientStatusChangeRec,ifcsc);
// clear notice notification

View File

@ -386,6 +386,8 @@ public class PrefsFragment extends Fragment {
SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
int sbProgress = slider.getProgress();
try {
// monitor and UI in two different processes. set static variable in both
Logging.setLogLevel(sbProgress);
BOINCActivity.monitor.setLogLevel(sbProgress);
} catch (RemoteException e) {}
updateValuePref(item.ID, (double) sbProgress);

View File

@ -33,6 +33,7 @@ import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.view.View.OnLongClickListener;
@ -57,6 +58,10 @@ public class SplashActivity extends Activity {
// This is called when the connection with the service has been established
mIsBound = true;
monitor = IMonitor.Stub.asInterface(service);
try {
// read log level from monitor preferences and adjust accordingly
Logging.setLogLevel(monitor.getLogLevel());
} catch (RemoteException e) {Log.w(Logging.TAG, "initializing log level failed.");}
}
public void onServiceDisconnected(ComponentName className) {
@ -85,7 +90,7 @@ public class SplashActivity extends Activity {
if(Logging.DEBUG) Log.d(Logging.TAG, "SplashActivity SETUP_STATUS_NOPROJECT");
// run benchmarks to speed up project initialization
boolean benchmarks = monitor.runBenchmarks();
Log.d(Logging.TAG, "SplashActivity: runBenchmarks returned: " + benchmarks);
if(Logging.DEBUG) Log.d(Logging.TAG, "SplashActivity: runBenchmarks returned: " + benchmarks);
// forward to PROJECTATTACH
Intent startAttach = new Intent(activity,AttachProjectListActivity.class);
startAttach.putExtra("showUp", false);
@ -107,19 +112,22 @@ public class SplashActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
//initialize logging with highest verbosity, read actual value when monitor connected.
Logging.setLogLevel(5);
// check whether PTG is installed, if not, do not start.
// this check has to be similar to client.Monitor.onCreate()
try {
getPackageManager().getPackageInfo("com.htc.ptg", 0);
if ("com.android.vending".equals(getPackageManager().getInstallerPackageName("com.htc.ptg")) // check if installed through PlayStore
|| (getPackageManager().getPackageInfo("com.htc.ptg", 0).applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == ApplicationInfo.FLAG_SYSTEM) { // check if pre-installed
Log.e(Logging.TAG, "SplashActivity: PTG found, show forward dialog.");
if(Logging.ERROR) Log.e(Logging.TAG, "SplashActivity: PTG found, show forward dialog.");
Intent startPTGIntent = new Intent();
startPTGIntent.setClassName("edu.berkeley.boinc", "edu.berkeley.boinc.ForwardDialog");
startActivity(startPTGIntent);
finish();
return;
} else Log.w(Logging.TAG,"SplashActivity: com.htc.ptg found, but unknown vendor, start BOINC...");
} else if(Logging.WARNING) Log.w(Logging.TAG,"SplashActivity: com.htc.ptg found, but unknown vendor, start BOINC...");
} catch (Exception ex) {} // NOP Package not found exception.
//bind monitor service