remove(driver-app): remove rit-driver-app from git repository and add to .gitignore
Some checks are pending
Deploy RIT Freshers Hub to VPS / Deploy to Live VPS (push) Waiting to run
Some checks are pending
Deploy RIT Freshers Hub to VPS / Deploy to Live VPS (push) Waiting to run
This commit is contained in:
@@ -1,33 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'com.android.application'
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
namespace 'com.rit.driver'
|
|
||||||
compileSdk 34
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "com.rit.driver"
|
|
||||||
minSdk 21
|
|
||||||
targetSdk 34
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_17
|
|
||||||
targetCompatibility JavaVersion.VERSION_17
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
||||||
implementation 'com.google.android.material:material:1.11.0'
|
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<!-- Location Permissions -->
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
|
||||||
|
|
||||||
<!-- Foreground Service Permissions -->
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
|
|
||||||
|
|
||||||
<!-- Wakelock and Network Permissions -->
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
||||||
|
|
||||||
<application
|
|
||||||
android:allowBackup="true"
|
|
||||||
android:icon="@drawable/ic_launcher"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:supportsRtl="true"
|
|
||||||
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
|
|
||||||
android:usesCleartextTraffic="true">
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".MainActivity"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<service
|
|
||||||
android:name=".TrackingService"
|
|
||||||
android:enabled="true"
|
|
||||||
android:exported="false"
|
|
||||||
android:foregroundServiceType="location" />
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.rit.driver;
|
|
||||||
|
|
||||||
public class Config {
|
|
||||||
|
|
||||||
public static final String BACKEND_URL = "https://rit-services.in";
|
|
||||||
|
|
||||||
|
|
||||||
public static final String DEFAULT_PIN = "RITDRIVER";
|
|
||||||
}
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
package com.rit.driver;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
private static final int PERMISSION_REQUEST_CODE = 888;
|
|
||||||
|
|
||||||
private EditText etRouteNumber;
|
|
||||||
private EditText etDriverPin;
|
|
||||||
private Button btnStartSharing;
|
|
||||||
private Button btnStopSharing;
|
|
||||||
private TextView tvStatusHeader;
|
|
||||||
private TextView tvStatusLogs;
|
|
||||||
private LinearLayout statusCard;
|
|
||||||
|
|
||||||
private boolean isServiceRunning = false;
|
|
||||||
|
|
||||||
// Receive tracking updates from Foreground Service
|
|
||||||
private final BroadcastReceiver locationReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (intent != null) {
|
|
||||||
if (intent.hasExtra(TrackingService.EXTRA_STATUS)) {
|
|
||||||
String status = intent.getStringExtra(TrackingService.EXTRA_STATUS);
|
|
||||||
tvStatusHeader.setText("STATUS: " + (isServiceRunning ? "ACTIVE" : "INACTIVE"));
|
|
||||||
logStatus(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (intent.hasExtra(TrackingService.EXTRA_LATITUDE) && intent.hasExtra(TrackingService.EXTRA_LONGITUDE)) {
|
|
||||||
double lat = intent.getDoubleExtra(TrackingService.EXTRA_LATITUDE, 0.0);
|
|
||||||
double lng = intent.getDoubleExtra(TrackingService.EXTRA_LONGITUDE, 0.0);
|
|
||||||
float accuracy = intent.getFloatExtra(TrackingService.EXTRA_ACCURACY, 0.0f);
|
|
||||||
|
|
||||||
String gpsInfo = String.format("GPS Coords: %.6f, %.6f\nAccuracy: ±%.1fm", lat, lng, accuracy);
|
|
||||||
logStatus(gpsInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
|
|
||||||
// Bind Views
|
|
||||||
etRouteNumber = findViewById(R.id.etRouteNumber);
|
|
||||||
etDriverPin = findViewById(R.id.etDriverPin);
|
|
||||||
etDriverPin.setText(Config.DEFAULT_PIN);
|
|
||||||
btnStartSharing = findViewById(R.id.btnStartSharing);
|
|
||||||
btnStopSharing = findViewById(R.id.btnStopSharing);
|
|
||||||
tvStatusHeader = findViewById(R.id.tvStatusHeader);
|
|
||||||
tvStatusLogs = findViewById(R.id.tvStatusLogs);
|
|
||||||
statusCard = findViewById(R.id.statusCard);
|
|
||||||
|
|
||||||
btnStartSharing.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (checkAndRequestPermissions()) {
|
|
||||||
startTracking();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
btnStopSharing.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
stopTracking();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
// Register receiver for service communication
|
|
||||||
IntentFilter filter = new IntentFilter(TrackingService.ACTION_LOCATION_BROADCAST);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
||||||
registerReceiver(locationReceiver, filter, Context.RECEIVER_EXPORTED);
|
|
||||||
} else {
|
|
||||||
registerReceiver(locationReceiver, filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
// Unregister receiver
|
|
||||||
unregisterReceiver(locationReceiver);
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startTracking() {
|
|
||||||
String serverUrl = Config.BACKEND_URL;
|
|
||||||
String routeNumber = etRouteNumber.getText().toString().trim();
|
|
||||||
String driverPin = etDriverPin.getText().toString().trim();
|
|
||||||
if (routeNumber.isEmpty()) {
|
|
||||||
Toast.makeText(this, "Enter bus route number", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (driverPin.isEmpty()) {
|
|
||||||
Toast.makeText(this, "Enter security driver PIN", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(this, TrackingService.class);
|
|
||||||
serviceIntent.putExtra("server_url", serverUrl);
|
|
||||||
serviceIntent.putExtra("route_number", routeNumber);
|
|
||||||
serviceIntent.putExtra("driver_pin", driverPin);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
startForegroundService(serviceIntent);
|
|
||||||
} else {
|
|
||||||
startService(serviceIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
isServiceRunning = true;
|
|
||||||
btnStartSharing.setVisibility(View.GONE);
|
|
||||||
btnStopSharing.setVisibility(View.VISIBLE);
|
|
||||||
tvStatusHeader.setText("STATUS: ACTIVE");
|
|
||||||
logStatus("Foreground tracking service started.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopTracking() {
|
|
||||||
Intent serviceIntent = new Intent(this, TrackingService.class);
|
|
||||||
stopService(serviceIntent);
|
|
||||||
|
|
||||||
isServiceRunning = false;
|
|
||||||
btnStartSharing.setVisibility(View.VISIBLE);
|
|
||||||
btnStopSharing.setVisibility(View.GONE);
|
|
||||||
tvStatusHeader.setText("STATUS: INACTIVE");
|
|
||||||
logStatus("Tracking stopped by driver.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void logStatus(String msg) {
|
|
||||||
String currentText = tvStatusLogs.getText().toString();
|
|
||||||
tvStatusLogs.setText(msg + "\n\n" + currentText);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean checkAndRequestPermissions() {
|
|
||||||
boolean hasFine = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
||||||
boolean hasCoarse = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
||||||
|
|
||||||
List<String> listPermissionsNeeded = new ArrayList<>();
|
|
||||||
|
|
||||||
if (!hasFine && !hasCoarse) {
|
|
||||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
|
||||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
listPermissionsNeeded.add(Manifest.permission.POST_NOTIFICATIONS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!listPermissionsNeeded.isEmpty()) {
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
this,
|
|
||||||
listPermissionsNeeded.toArray(new String[0]),
|
|
||||||
PERMISSION_REQUEST_CODE
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
if (requestCode == PERMISSION_REQUEST_CODE) {
|
|
||||||
boolean hasFine = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
||||||
boolean hasCoarse = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
||||||
|
|
||||||
if (hasFine || hasCoarse) {
|
|
||||||
startTracking();
|
|
||||||
} else {
|
|
||||||
Toast.makeText(this, "Location permission (Precise or Approximate) is required to track the bus.", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
package com.rit.driver;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class NetworkHelper {
|
|
||||||
|
|
||||||
private static final String TAG = "NetworkHelper";
|
|
||||||
|
|
||||||
public interface Callback {
|
|
||||||
void onSuccess();
|
|
||||||
void onFailure(String error);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void postLocation(final String serverUrl, final String routeNumber, final double lat, final double lng, final String pin, final Callback callback) {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
HttpURLConnection conn = null;
|
|
||||||
try {
|
|
||||||
// Clean URL trailing slash and route mapping
|
|
||||||
String cleanUrl = serverUrl;
|
|
||||||
if (cleanUrl.endsWith("/")) {
|
|
||||||
cleanUrl = cleanUrl.substring(0, cleanUrl.length() - 1);
|
|
||||||
}
|
|
||||||
String targetUrl = cleanUrl + "/api/bus-locations/" + routeNumber;
|
|
||||||
|
|
||||||
URL url = new URL(targetUrl);
|
|
||||||
conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("POST");
|
|
||||||
conn.setRequestProperty("Content-Type", "application/json");
|
|
||||||
conn.setDoOutput(true);
|
|
||||||
conn.setConnectTimeout(8000);
|
|
||||||
conn.setReadTimeout(8000);
|
|
||||||
|
|
||||||
// Build JSON string payload using Locale.US to ensure dot decimals in JSON
|
|
||||||
String jsonInputString = String.format(
|
|
||||||
java.util.Locale.US,
|
|
||||||
"{\"latitude\": %.6f, \"longitude\": %.6f, \"pin\": \"%s\"}",
|
|
||||||
lat, lng, pin
|
|
||||||
);
|
|
||||||
|
|
||||||
try (OutputStream os = conn.getOutputStream()) {
|
|
||||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
|
||||||
os.write(input, 0, input.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
int code = conn.getResponseCode();
|
|
||||||
if (code == 200 || code == 201) {
|
|
||||||
Log.d(TAG, "Location uploaded successfully: " + code);
|
|
||||||
if (callback != null) {
|
|
||||||
callback.onSuccess();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String errMsg = "HTTP error code " + code;
|
|
||||||
Log.w(TAG, errMsg);
|
|
||||||
if (callback != null) {
|
|
||||||
callback.onFailure(errMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
String errMsg = "Upload failed: " + e.getMessage();
|
|
||||||
Log.e(TAG, errMsg, e);
|
|
||||||
if (callback != null) {
|
|
||||||
callback.onFailure(errMsg);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (conn != null) {
|
|
||||||
conn.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,253 +0,0 @@
|
|||||||
package com.rit.driver;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.NotificationChannel;
|
|
||||||
import android.app.NotificationManager;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.location.Location;
|
|
||||||
import android.location.LocationListener;
|
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.util.Log;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.core.app.NotificationCompat;
|
|
||||||
|
|
||||||
public class TrackingService extends Service {
|
|
||||||
|
|
||||||
private static final String TAG = "TrackingService";
|
|
||||||
private static final String CHANNEL_ID = "TrackingServiceChannel";
|
|
||||||
private static final int NOTIFICATION_ID = 444;
|
|
||||||
|
|
||||||
private LocationManager locationManager;
|
|
||||||
private PowerManager.WakeLock wakeLock;
|
|
||||||
|
|
||||||
private String serverUrl = "";
|
|
||||||
private String routeNumber = "";
|
|
||||||
private String driverPin = "";
|
|
||||||
|
|
||||||
// Broadcast action for MainActivity to update UI coordinates
|
|
||||||
public static final String ACTION_LOCATION_BROADCAST = "com.rit.driver.LOCATION_BROADCAST";
|
|
||||||
public static final String EXTRA_LATITUDE = "extra_latitude";
|
|
||||||
public static final String EXTRA_LONGITUDE = "extra_longitude";
|
|
||||||
public static final String EXTRA_ACCURACY = "extra_accuracy";
|
|
||||||
public static final String EXTRA_STATUS = "extra_status";
|
|
||||||
|
|
||||||
private final LocationListener locationListener = new LocationListener() {
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(Location location) {
|
|
||||||
double lat = location.getLatitude();
|
|
||||||
double lng = location.getLongitude();
|
|
||||||
float accuracy = location.getAccuracy();
|
|
||||||
|
|
||||||
Log.d(TAG, "Location updated: " + lat + ", " + lng + " (Accuracy: " + accuracy + "m)");
|
|
||||||
|
|
||||||
// Broadcast updates locally to MainActivity UI
|
|
||||||
Intent broadcastIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
|
||||||
broadcastIntent.setPackage(getPackageName());
|
|
||||||
broadcastIntent.putExtra(EXTRA_LATITUDE, lat);
|
|
||||||
broadcastIntent.putExtra(EXTRA_LONGITUDE, lng);
|
|
||||||
broadcastIntent.putExtra(EXTRA_ACCURACY, accuracy);
|
|
||||||
broadcastIntent.putExtra(EXTRA_STATUS, "Broadcasting Location...");
|
|
||||||
sendBroadcast(broadcastIntent);
|
|
||||||
|
|
||||||
// Upload location to backend
|
|
||||||
NetworkHelper.postLocation(serverUrl, routeNumber, lat, lng, driverPin, new NetworkHelper.Callback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess() {
|
|
||||||
Log.d(TAG, "Uploaded location successfully");
|
|
||||||
Intent statusIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
|
||||||
statusIntent.setPackage(getPackageName());
|
|
||||||
statusIntent.putExtra(EXTRA_STATUS, "Upload Success: Location synced.");
|
|
||||||
sendBroadcast(statusIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(String error) {
|
|
||||||
Log.e(TAG, "Upload failed: " + error);
|
|
||||||
Intent statusIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
|
||||||
statusIntent.setPackage(getPackageName());
|
|
||||||
statusIntent.putExtra(EXTRA_STATUS, "Upload Failed: " + error);
|
|
||||||
sendBroadcast(statusIntent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderEnabled(String provider) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderDisabled(String provider) {
|
|
||||||
Intent statusIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
|
||||||
statusIntent.setPackage(getPackageName());
|
|
||||||
statusIntent.putExtra(EXTRA_STATUS, "GPS Provider Disabled. Please turn on Location/GPS.");
|
|
||||||
sendBroadcast(statusIntent);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate() {
|
|
||||||
super.onCreate();
|
|
||||||
Log.d(TAG, "onCreate: Service starting");
|
|
||||||
createNotificationChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private android.os.Handler handler = new android.os.Handler(android.os.Looper.getMainLooper());
|
|
||||||
private Runnable periodicUploader = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
Location loc = null;
|
|
||||||
if (locationManager != null) {
|
|
||||||
try {
|
|
||||||
Location gpsLoc = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
|
||||||
Location netLoc = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
|
||||||
Location pasLoc = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
|
|
||||||
|
|
||||||
// Find newest location fix
|
|
||||||
if (gpsLoc != null) loc = gpsLoc;
|
|
||||||
if (netLoc != null && (loc == null || netLoc.getTime() > loc.getTime())) loc = netLoc;
|
|
||||||
if (pasLoc != null && (loc == null || pasLoc.getTime() > loc.getTime())) loc = pasLoc;
|
|
||||||
} catch (SecurityException ignored) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If indoors with zero GPS fix, fallback to campus location fix
|
|
||||||
if (loc == null) {
|
|
||||||
loc = new Location("IndoorFallback");
|
|
||||||
loc.setLatitude(13.0118);
|
|
||||||
loc.setLongitude(80.0214);
|
|
||||||
loc.setAccuracy(15.0f);
|
|
||||||
loc.setTime(System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
locationListener.onLocationChanged(loc);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Error in periodic uploader: " + e.getMessage());
|
|
||||||
} finally {
|
|
||||||
handler.postDelayed(this, 5000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@SuppressLint("InvalidWakeLockTag")
|
|
||||||
@Override
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
||||||
Log.d(TAG, "onStartCommand: Service active");
|
|
||||||
|
|
||||||
if (intent != null) {
|
|
||||||
serverUrl = intent.getStringExtra("server_url");
|
|
||||||
routeNumber = intent.getStringExtra("route_number");
|
|
||||||
driverPin = intent.getStringExtra("driver_pin");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. Show Foreground Notification
|
|
||||||
Intent notificationIntent = new Intent(this, MainActivity.class);
|
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(
|
|
||||||
this, 0, notificationIntent,
|
|
||||||
PendingIntent.FLAG_IMMUTABLE
|
|
||||||
);
|
|
||||||
|
|
||||||
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
|
|
||||||
.setContentTitle("RIT Driver Tracker")
|
|
||||||
.setContentText("Active Journey: Route " + routeNumber + " is currently tracking...")
|
|
||||||
.setSmallIcon(android.R.drawable.ic_menu_compass)
|
|
||||||
.setContentIntent(pendingIntent)
|
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
startForeground(NOTIFICATION_ID, notification, android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION);
|
|
||||||
} else {
|
|
||||||
startForeground(NOTIFICATION_ID, notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Acquire Power CPU WakeLock
|
|
||||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
|
||||||
if (pm != null) {
|
|
||||||
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TrackingService::WakeLock");
|
|
||||||
wakeLock.acquire();
|
|
||||||
Log.d(TAG, "WakeLock acquired successfully");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Register Location Listeners (both GPS and Network for indoors/outdoors)
|
|
||||||
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
|
||||||
try {
|
|
||||||
if (locationManager != null) {
|
|
||||||
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
|
||||||
try {
|
|
||||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 0.0f, locationListener);
|
|
||||||
} catch (SecurityException ignored) {}
|
|
||||||
}
|
|
||||||
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
|
|
||||||
try {
|
|
||||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 3000, 0.0f, locationListener);
|
|
||||||
} catch (SecurityException ignored) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Location permission warning", e);
|
|
||||||
Intent statusIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
|
||||||
statusIntent.setPackage(getPackageName());
|
|
||||||
statusIntent.putExtra(EXTRA_STATUS, "Location Warning: " + e.getMessage());
|
|
||||||
sendBroadcast(statusIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Start periodic 5-second uploader
|
|
||||||
handler.removeCallbacks(periodicUploader);
|
|
||||||
handler.post(periodicUploader);
|
|
||||||
|
|
||||||
return START_REDELIVER_INTENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
Log.d(TAG, "onDestroy: Stopping service cleanups");
|
|
||||||
|
|
||||||
// Stop periodic uploader timer
|
|
||||||
if (handler != null && periodicUploader != null) {
|
|
||||||
handler.removeCallbacks(periodicUploader);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. Remove GPS Listener
|
|
||||||
if (locationManager != null) {
|
|
||||||
locationManager.removeUpdates(locationListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Release CPU WakeLock
|
|
||||||
if (wakeLock != null && wakeLock.isHeld()) {
|
|
||||||
wakeLock.release();
|
|
||||||
Log.d(TAG, "WakeLock released cleanly");
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createNotificationChannel() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
NotificationChannel serviceChannel = new NotificationChannel(
|
|
||||||
CHANNEL_ID,
|
|
||||||
"RIT Driver Tracker Channel",
|
|
||||||
NotificationManager.IMPORTANCE_DEFAULT
|
|
||||||
);
|
|
||||||
NotificationManager manager = getSystemService(NotificationManager.class);
|
|
||||||
if (manager != null) {
|
|
||||||
manager.createNotificationChannel(serviceChannel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="108dp"
|
|
||||||
android:height="108dp"
|
|
||||||
android:viewportWidth="108"
|
|
||||||
android:viewportHeight="108">
|
|
||||||
<path
|
|
||||||
android:fillColor="#1E293B"
|
|
||||||
android:pathData="M0,0h108v108h-108z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#F97316"
|
|
||||||
android:pathData="M54,20 C35.22,20 20,35.22 20,54 C20,72.78 35.22,88 54,88 C72.78,88 88,72.78 88,54 C88,35.22 72.78,20 54,20 Z M54,76 C41.85,76 32,66.15 32,54 C32,41.85 41.85,32 54,32 C66.15,32 76,41.85 76,54 C76,66.15 66.15,76 54,76 Z M54,40 L60,54 L54,68 L48,54 Z" />
|
|
||||||
</vector>
|
|
||||||
@@ -1,161 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fillViewport="true"
|
|
||||||
android:background="#1E293B"
|
|
||||||
tools:context=".MainActivity">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="20dp">
|
|
||||||
|
|
||||||
<!-- Title -->
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="RIT Driver Tracker"
|
|
||||||
android:textColor="#FFFFFF"
|
|
||||||
android:textSize="26sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginBottom="6dp"
|
|
||||||
tools:ignore="HardcodedText" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Live Background Geolocation Broadcaster"
|
|
||||||
android:textColor="#94A3B8"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginBottom="24dp"
|
|
||||||
tools:ignore="HardcodedText" />
|
|
||||||
|
|
||||||
<!-- Route Number Input -->
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="BUS ROUTE NUMBER"
|
|
||||||
android:textColor="#94A3B8"
|
|
||||||
android:textSize="11sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:layout_marginBottom="6dp"
|
|
||||||
tools:ignore="HardcodedText" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/etRouteNumber"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="52dp"
|
|
||||||
android:background="@android:drawable/editbox_background"
|
|
||||||
android:hint="R01"
|
|
||||||
android:text="R01"
|
|
||||||
android:inputType="textCapCharacters"
|
|
||||||
android:padding="12dp"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="#0F172A"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
tools:ignore="HardcodedText,Autofill,TextFields" />
|
|
||||||
|
|
||||||
<!-- Driver PIN Input -->
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="DRIVER SECURITY PIN"
|
|
||||||
android:textColor="#94A3B8"
|
|
||||||
android:textSize="11sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:layout_marginBottom="6dp"
|
|
||||||
tools:ignore="HardcodedText" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/etDriverPin"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="52dp"
|
|
||||||
android:background="@android:drawable/editbox_background"
|
|
||||||
android:hint="Enter Security PIN"
|
|
||||||
android:text="RITDRIVER"
|
|
||||||
android:inputType="textPassword"
|
|
||||||
android:padding="12dp"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="#0F172A"
|
|
||||||
android:layout_marginBottom="24dp"
|
|
||||||
tools:ignore="HardcodedText,Autofill,TextFields" />
|
|
||||||
|
|
||||||
<!-- Start Sharing Button -->
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btnStartSharing"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:backgroundTint="#F97316"
|
|
||||||
android:text="START LOCATION SHARING"
|
|
||||||
android:textColor="#FFFFFF"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:layout_marginBottom="14dp"
|
|
||||||
tools:ignore="HardcodedText,VisualLintButtonSize" />
|
|
||||||
|
|
||||||
<!-- Stop Sharing Button -->
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btnStopSharing"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:backgroundTint="#EF4444"
|
|
||||||
android:text="STOP LOCATION SHARING"
|
|
||||||
android:textColor="#FFFFFF"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_marginBottom="20dp"
|
|
||||||
tools:ignore="HardcodedText,VisualLintButtonSize" />
|
|
||||||
|
|
||||||
<!-- Status Card -->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/statusCard"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="#0F172A"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:visibility="visible">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvStatusHeader"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="STATUS: INACTIVE"
|
|
||||||
android:textColor="#F1F5F9"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
tools:ignore="HardcodedText" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvStatusLogs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Toggle location sharing to begin tracking.\nKeep phone screen turned on or off — the app will broadcast fine coordinates in the background."
|
|
||||||
android:textColor="#94A3B8"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:lineSpacingExtra="3dp"
|
|
||||||
tools:ignore="HardcodedText" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- Keep screen notice -->
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Notice: Once active, you can lock the screen or close the app interface. The native system foreground notification service keeps tracking alive."
|
|
||||||
android:textColor="#64748B"
|
|
||||||
android:textSize="11sp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_marginBottom="20dp"
|
|
||||||
tools:ignore="HardcodedText,SmallSp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">RIT Driver Tracker</string>
|
|
||||||
</resources>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
||||||
plugins {
|
|
||||||
id 'com.android.application' version '8.7.2' apply false
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# Project-wide Gradle settings.
|
|
||||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
|
||||||
android.useAndroidX=true
|
|
||||||
android.enableJetifier=true
|
|
||||||
BIN
rit-driver-app/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
rit-driver-app/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@@ -1,7 +0,0 @@
|
|||||||
#Fri Jul 24 14:49:37 IST 2026
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
||||||
248
rit-driver-app/gradlew
vendored
248
rit-driver-app/gradlew
vendored
@@ -1,248 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright © 2015 the original authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
|
||||||
#
|
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
app_path=$0
|
|
||||||
|
|
||||||
# Need this for daisy-chained symlinks.
|
|
||||||
while
|
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
||||||
[ -h "$app_path" ]
|
|
||||||
do
|
|
||||||
ls=$( ls -ld "$app_path" )
|
|
||||||
link=${ls#*' -> '}
|
|
||||||
case $link in #(
|
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# This is normally unused
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD=maximum
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "$( uname )" in #(
|
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
|
||||||
Darwin* ) darwin=true ;; #(
|
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
|
||||||
NONSTOP* ) nonstop=true ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
||||||
else
|
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
|
||||||
fi
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD=java
|
|
||||||
if ! command -v java >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
||||||
case $MAX_FD in #(
|
|
||||||
max*)
|
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
||||||
# shellcheck disable=SC2039,SC3045
|
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
|
||||||
warn "Could not query maximum file descriptor limit"
|
|
||||||
esac
|
|
||||||
case $MAX_FD in #(
|
|
||||||
'' | soft) :;; #(
|
|
||||||
*)
|
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
||||||
# shellcheck disable=SC2039,SC3045
|
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
|
||||||
# * args from the command line
|
|
||||||
# * the main class name
|
|
||||||
# * -classpath
|
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if "$cygwin" || "$msys" ; then
|
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
for arg do
|
|
||||||
if
|
|
||||||
case $arg in #(
|
|
||||||
-*) false ;; # don't mess with options #(
|
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
||||||
# and any embedded shellness will be escaped.
|
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
||||||
# treated as '${Hostname}' itself on the command line.
|
|
||||||
|
|
||||||
set -- \
|
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
|
||||||
if ! command -v xargs >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "xargs is not available"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
||||||
93
rit-driver-app/gradlew.bat
vendored
93
rit-driver-app/gradlew.bat
vendored
@@ -1,93 +0,0 @@
|
|||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
|
||||||
@rem ##########################################################################
|
|
||||||
@rem
|
|
||||||
@rem Gradle startup script for Windows
|
|
||||||
@rem
|
|
||||||
@rem ##########################################################################
|
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
|
||||||
@rem This is normally unused
|
|
||||||
set APP_BASE_NAME=%~n0
|
|
||||||
set APP_HOME=%DIRNAME%
|
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
||||||
|
|
||||||
@rem Find java.exe
|
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
|
||||||
|
|
||||||
echo. 1>&2
|
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
|
||||||
echo. 1>&2
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
||||||
echo location of your Java installation. 1>&2
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
|
||||||
|
|
||||||
echo. 1>&2
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
|
||||||
echo. 1>&2
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
||||||
echo location of your Java installation. 1>&2
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
|
||||||
|
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
||||||
|
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
## This file must *NOT* be checked into Version Control Systems,
|
|
||||||
# as it contains information specific to your local configuration.
|
|
||||||
#
|
|
||||||
# Location of the SDK. This is only used by Gradle.
|
|
||||||
# For customization when using a Version Control System, please read the
|
|
||||||
# header note.
|
|
||||||
#Fri Jul 24 14:24:21 IST 2026
|
|
||||||
sdk.dir=C\:\\Users\\dorut\\AppData\\Local\\Android\\Sdk
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencyResolutionManagement {
|
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = "RIT Driver Tracker"
|
|
||||||
include ':app'
|
|
||||||
Reference in New Issue
Block a user